{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoTEvents.Types.DynamoDBAction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTEvents.Types.DynamoDBAction 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.Payload
import qualified Amazonka.Prelude as Prelude

-- | Defines an action to write to the Amazon DynamoDB table that you
-- created. The standard action payload contains all the information about
-- the detector model instance and the event that triggered the action. You
-- can customize the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
-- One column of the DynamoDB table receives all attribute-value pairs in
-- the payload that you specify.
--
-- You must use expressions for all parameters in @DynamoDBAction@. The
-- expressions accept literals, operators, functions, references, and
-- substitution templates.
--
-- __Examples__
--
-- -   For literal values, the expressions must contain single quotes. For
--     example, the value for the @hashKeyType@ parameter can be
--     @\'STRING\'@.
--
-- -   For references, you must specify either variables or input values.
--     For example, the value for the @hashKeyField@ parameter can be
--     @$input.GreenhouseInput.name@.
--
-- -   For a substitution template, you must use @${}@, and the template
--     must be in single quotes. A substitution template can also contain a
--     combination of literals, operators, functions, references, and
--     substitution templates.
--
--     In the following example, the value for the @hashKeyValue@ parameter
--     uses a substitution template.
--
--     @\'${$input.GreenhouseInput.temperature * 6 \/ 5 + 32} in Fahrenheit\'@
--
-- -   For a string concatenation, you must use @+@. A string concatenation
--     can also contain a combination of literals, operators, functions,
--     references, and substitution templates.
--
--     In the following example, the value for the @tableName@ parameter
--     uses a string concatenation.
--
--     @\'GreenhouseTemperatureTable \' + $input.GreenhouseInput.date@
--
-- For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-expressions.html Expressions>
-- in the /AWS IoT Events Developer Guide/.
--
-- If the defined payload type is a string, @DynamoDBAction@ writes
-- non-JSON data to the DynamoDB table as binary data. The DynamoDB console
-- displays the data as Base64-encoded text. The value for the
-- @payloadField@ parameter is @\<payload-field>_raw@.
--
-- /See:/ 'newDynamoDBAction' smart constructor.
data DynamoDBAction = DynamoDBAction'
  { -- | The data type for the hash key (also called the partition key). You can
    -- specify the following values:
    --
    -- -   @\'STRING\'@ - The hash key is a string.
    --
    -- -   @\'NUMBER\'@ - The hash key is a number.
    --
    -- If you don\'t specify @hashKeyType@, the default value is @\'STRING\'@.
    DynamoDBAction -> Maybe Text
hashKeyType :: Prelude.Maybe Prelude.Text,
    -- | The type of operation to perform. You can specify the following values:
    --
    -- -   @\'INSERT\'@ - Insert data as a new item into the DynamoDB table.
    --     This item uses the specified hash key as a partition key. If you
    --     specified a range key, the item uses the range key as a sort key.
    --
    -- -   @\'UPDATE\'@ - Update an existing item of the DynamoDB table with
    --     new data. This item\'s partition key must match the specified hash
    --     key. If you specified a range key, the range key must match the
    --     item\'s sort key.
    --
    -- -   @\'DELETE\'@ - Delete an existing item of the DynamoDB table. This
    --     item\'s partition key must match the specified hash key. If you
    --     specified a range key, the range key must match the item\'s sort
    --     key.
    --
    -- If you don\'t specify this parameter, AWS IoT Events triggers the
    -- @\'INSERT\'@ operation.
    DynamoDBAction -> Maybe Text
operation :: Prelude.Maybe Prelude.Text,
    DynamoDBAction -> Maybe Payload
payload :: Prelude.Maybe Payload,
    -- | The name of the DynamoDB column that receives the action payload.
    --
    -- If you don\'t specify this parameter, the name of the DynamoDB column is
    -- @payload@.
    DynamoDBAction -> Maybe Text
payloadField :: Prelude.Maybe Prelude.Text,
    -- | The name of the range key (also called the sort key). The
    -- @rangeKeyField@ value must match the sort key of the target DynamoDB
    -- table.
    DynamoDBAction -> Maybe Text
rangeKeyField :: Prelude.Maybe Prelude.Text,
    -- | The data type for the range key (also called the sort key), You can
    -- specify the following values:
    --
    -- -   @\'STRING\'@ - The range key is a string.
    --
    -- -   @\'NUMBER\'@ - The range key is number.
    --
    -- If you don\'t specify @rangeKeyField@, the default value is
    -- @\'STRING\'@.
    DynamoDBAction -> Maybe Text
rangeKeyType :: Prelude.Maybe Prelude.Text,
    -- | The value of the range key (also called the sort key).
    DynamoDBAction -> Maybe Text
rangeKeyValue :: Prelude.Maybe Prelude.Text,
    -- | The name of the hash key (also called the partition key). The
    -- @hashKeyField@ value must match the partition key of the target DynamoDB
    -- table.
    DynamoDBAction -> Text
hashKeyField :: Prelude.Text,
    -- | The value of the hash key (also called the partition key).
    DynamoDBAction -> Text
hashKeyValue :: Prelude.Text,
    -- | The name of the DynamoDB table. The @tableName@ value must match the
    -- table name of the target DynamoDB table.
    DynamoDBAction -> Text
tableName :: Prelude.Text
  }
  deriving (DynamoDBAction -> DynamoDBAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DynamoDBAction -> DynamoDBAction -> Bool
$c/= :: DynamoDBAction -> DynamoDBAction -> Bool
== :: DynamoDBAction -> DynamoDBAction -> Bool
$c== :: DynamoDBAction -> DynamoDBAction -> Bool
Prelude.Eq, ReadPrec [DynamoDBAction]
ReadPrec DynamoDBAction
Int -> ReadS DynamoDBAction
ReadS [DynamoDBAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DynamoDBAction]
$creadListPrec :: ReadPrec [DynamoDBAction]
readPrec :: ReadPrec DynamoDBAction
$creadPrec :: ReadPrec DynamoDBAction
readList :: ReadS [DynamoDBAction]
$creadList :: ReadS [DynamoDBAction]
readsPrec :: Int -> ReadS DynamoDBAction
$creadsPrec :: Int -> ReadS DynamoDBAction
Prelude.Read, Int -> DynamoDBAction -> ShowS
[DynamoDBAction] -> ShowS
DynamoDBAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DynamoDBAction] -> ShowS
$cshowList :: [DynamoDBAction] -> ShowS
show :: DynamoDBAction -> String
$cshow :: DynamoDBAction -> String
showsPrec :: Int -> DynamoDBAction -> ShowS
$cshowsPrec :: Int -> DynamoDBAction -> ShowS
Prelude.Show, forall x. Rep DynamoDBAction x -> DynamoDBAction
forall x. DynamoDBAction -> Rep DynamoDBAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DynamoDBAction x -> DynamoDBAction
$cfrom :: forall x. DynamoDBAction -> Rep DynamoDBAction x
Prelude.Generic)

-- |
-- Create a value of 'DynamoDBAction' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'hashKeyType', 'dynamoDBAction_hashKeyType' - The data type for the hash key (also called the partition key). You can
-- specify the following values:
--
-- -   @\'STRING\'@ - The hash key is a string.
--
-- -   @\'NUMBER\'@ - The hash key is a number.
--
-- If you don\'t specify @hashKeyType@, the default value is @\'STRING\'@.
--
-- 'operation', 'dynamoDBAction_operation' - The type of operation to perform. You can specify the following values:
--
-- -   @\'INSERT\'@ - Insert data as a new item into the DynamoDB table.
--     This item uses the specified hash key as a partition key. If you
--     specified a range key, the item uses the range key as a sort key.
--
-- -   @\'UPDATE\'@ - Update an existing item of the DynamoDB table with
--     new data. This item\'s partition key must match the specified hash
--     key. If you specified a range key, the range key must match the
--     item\'s sort key.
--
-- -   @\'DELETE\'@ - Delete an existing item of the DynamoDB table. This
--     item\'s partition key must match the specified hash key. If you
--     specified a range key, the range key must match the item\'s sort
--     key.
--
-- If you don\'t specify this parameter, AWS IoT Events triggers the
-- @\'INSERT\'@ operation.
--
-- 'payload', 'dynamoDBAction_payload' - Undocumented member.
--
-- 'payloadField', 'dynamoDBAction_payloadField' - The name of the DynamoDB column that receives the action payload.
--
-- If you don\'t specify this parameter, the name of the DynamoDB column is
-- @payload@.
--
-- 'rangeKeyField', 'dynamoDBAction_rangeKeyField' - The name of the range key (also called the sort key). The
-- @rangeKeyField@ value must match the sort key of the target DynamoDB
-- table.
--
-- 'rangeKeyType', 'dynamoDBAction_rangeKeyType' - The data type for the range key (also called the sort key), You can
-- specify the following values:
--
-- -   @\'STRING\'@ - The range key is a string.
--
-- -   @\'NUMBER\'@ - The range key is number.
--
-- If you don\'t specify @rangeKeyField@, the default value is
-- @\'STRING\'@.
--
-- 'rangeKeyValue', 'dynamoDBAction_rangeKeyValue' - The value of the range key (also called the sort key).
--
-- 'hashKeyField', 'dynamoDBAction_hashKeyField' - The name of the hash key (also called the partition key). The
-- @hashKeyField@ value must match the partition key of the target DynamoDB
-- table.
--
-- 'hashKeyValue', 'dynamoDBAction_hashKeyValue' - The value of the hash key (also called the partition key).
--
-- 'tableName', 'dynamoDBAction_tableName' - The name of the DynamoDB table. The @tableName@ value must match the
-- table name of the target DynamoDB table.
newDynamoDBAction ::
  -- | 'hashKeyField'
  Prelude.Text ->
  -- | 'hashKeyValue'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  DynamoDBAction
newDynamoDBAction :: Text -> Text -> Text -> DynamoDBAction
newDynamoDBAction
  Text
pHashKeyField_
  Text
pHashKeyValue_
  Text
pTableName_ =
    DynamoDBAction'
      { $sel:hashKeyType:DynamoDBAction' :: Maybe Text
hashKeyType = forall a. Maybe a
Prelude.Nothing,
        $sel:operation:DynamoDBAction' :: Maybe Text
operation = forall a. Maybe a
Prelude.Nothing,
        $sel:payload:DynamoDBAction' :: Maybe Payload
payload = forall a. Maybe a
Prelude.Nothing,
        $sel:payloadField:DynamoDBAction' :: Maybe Text
payloadField = forall a. Maybe a
Prelude.Nothing,
        $sel:rangeKeyField:DynamoDBAction' :: Maybe Text
rangeKeyField = forall a. Maybe a
Prelude.Nothing,
        $sel:rangeKeyType:DynamoDBAction' :: Maybe Text
rangeKeyType = forall a. Maybe a
Prelude.Nothing,
        $sel:rangeKeyValue:DynamoDBAction' :: Maybe Text
rangeKeyValue = forall a. Maybe a
Prelude.Nothing,
        $sel:hashKeyField:DynamoDBAction' :: Text
hashKeyField = Text
pHashKeyField_,
        $sel:hashKeyValue:DynamoDBAction' :: Text
hashKeyValue = Text
pHashKeyValue_,
        $sel:tableName:DynamoDBAction' :: Text
tableName = Text
pTableName_
      }

-- | The data type for the hash key (also called the partition key). You can
-- specify the following values:
--
-- -   @\'STRING\'@ - The hash key is a string.
--
-- -   @\'NUMBER\'@ - The hash key is a number.
--
-- If you don\'t specify @hashKeyType@, the default value is @\'STRING\'@.
dynamoDBAction_hashKeyType :: Lens.Lens' DynamoDBAction (Prelude.Maybe Prelude.Text)
dynamoDBAction_hashKeyType :: Lens' DynamoDBAction (Maybe Text)
dynamoDBAction_hashKeyType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Text
hashKeyType :: Maybe Text
$sel:hashKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
hashKeyType} -> Maybe Text
hashKeyType) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Text
a -> DynamoDBAction
s {$sel:hashKeyType:DynamoDBAction' :: Maybe Text
hashKeyType = Maybe Text
a} :: DynamoDBAction)

-- | The type of operation to perform. You can specify the following values:
--
-- -   @\'INSERT\'@ - Insert data as a new item into the DynamoDB table.
--     This item uses the specified hash key as a partition key. If you
--     specified a range key, the item uses the range key as a sort key.
--
-- -   @\'UPDATE\'@ - Update an existing item of the DynamoDB table with
--     new data. This item\'s partition key must match the specified hash
--     key. If you specified a range key, the range key must match the
--     item\'s sort key.
--
-- -   @\'DELETE\'@ - Delete an existing item of the DynamoDB table. This
--     item\'s partition key must match the specified hash key. If you
--     specified a range key, the range key must match the item\'s sort
--     key.
--
-- If you don\'t specify this parameter, AWS IoT Events triggers the
-- @\'INSERT\'@ operation.
dynamoDBAction_operation :: Lens.Lens' DynamoDBAction (Prelude.Maybe Prelude.Text)
dynamoDBAction_operation :: Lens' DynamoDBAction (Maybe Text)
dynamoDBAction_operation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Text
operation :: Maybe Text
$sel:operation:DynamoDBAction' :: DynamoDBAction -> Maybe Text
operation} -> Maybe Text
operation) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Text
a -> DynamoDBAction
s {$sel:operation:DynamoDBAction' :: Maybe Text
operation = Maybe Text
a} :: DynamoDBAction)

-- | Undocumented member.
dynamoDBAction_payload :: Lens.Lens' DynamoDBAction (Prelude.Maybe Payload)
dynamoDBAction_payload :: Lens' DynamoDBAction (Maybe Payload)
dynamoDBAction_payload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Payload
payload :: Maybe Payload
$sel:payload:DynamoDBAction' :: DynamoDBAction -> Maybe Payload
payload} -> Maybe Payload
payload) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Payload
a -> DynamoDBAction
s {$sel:payload:DynamoDBAction' :: Maybe Payload
payload = Maybe Payload
a} :: DynamoDBAction)

-- | The name of the DynamoDB column that receives the action payload.
--
-- If you don\'t specify this parameter, the name of the DynamoDB column is
-- @payload@.
dynamoDBAction_payloadField :: Lens.Lens' DynamoDBAction (Prelude.Maybe Prelude.Text)
dynamoDBAction_payloadField :: Lens' DynamoDBAction (Maybe Text)
dynamoDBAction_payloadField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Text
payloadField :: Maybe Text
$sel:payloadField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
payloadField} -> Maybe Text
payloadField) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Text
a -> DynamoDBAction
s {$sel:payloadField:DynamoDBAction' :: Maybe Text
payloadField = Maybe Text
a} :: DynamoDBAction)

-- | The name of the range key (also called the sort key). The
-- @rangeKeyField@ value must match the sort key of the target DynamoDB
-- table.
dynamoDBAction_rangeKeyField :: Lens.Lens' DynamoDBAction (Prelude.Maybe Prelude.Text)
dynamoDBAction_rangeKeyField :: Lens' DynamoDBAction (Maybe Text)
dynamoDBAction_rangeKeyField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Text
rangeKeyField :: Maybe Text
$sel:rangeKeyField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
rangeKeyField} -> Maybe Text
rangeKeyField) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Text
a -> DynamoDBAction
s {$sel:rangeKeyField:DynamoDBAction' :: Maybe Text
rangeKeyField = Maybe Text
a} :: DynamoDBAction)

-- | The data type for the range key (also called the sort key), You can
-- specify the following values:
--
-- -   @\'STRING\'@ - The range key is a string.
--
-- -   @\'NUMBER\'@ - The range key is number.
--
-- If you don\'t specify @rangeKeyField@, the default value is
-- @\'STRING\'@.
dynamoDBAction_rangeKeyType :: Lens.Lens' DynamoDBAction (Prelude.Maybe Prelude.Text)
dynamoDBAction_rangeKeyType :: Lens' DynamoDBAction (Maybe Text)
dynamoDBAction_rangeKeyType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Text
rangeKeyType :: Maybe Text
$sel:rangeKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
rangeKeyType} -> Maybe Text
rangeKeyType) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Text
a -> DynamoDBAction
s {$sel:rangeKeyType:DynamoDBAction' :: Maybe Text
rangeKeyType = Maybe Text
a} :: DynamoDBAction)

-- | The value of the range key (also called the sort key).
dynamoDBAction_rangeKeyValue :: Lens.Lens' DynamoDBAction (Prelude.Maybe Prelude.Text)
dynamoDBAction_rangeKeyValue :: Lens' DynamoDBAction (Maybe Text)
dynamoDBAction_rangeKeyValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Maybe Text
rangeKeyValue :: Maybe Text
$sel:rangeKeyValue:DynamoDBAction' :: DynamoDBAction -> Maybe Text
rangeKeyValue} -> Maybe Text
rangeKeyValue) (\s :: DynamoDBAction
s@DynamoDBAction' {} Maybe Text
a -> DynamoDBAction
s {$sel:rangeKeyValue:DynamoDBAction' :: Maybe Text
rangeKeyValue = Maybe Text
a} :: DynamoDBAction)

-- | The name of the hash key (also called the partition key). The
-- @hashKeyField@ value must match the partition key of the target DynamoDB
-- table.
dynamoDBAction_hashKeyField :: Lens.Lens' DynamoDBAction Prelude.Text
dynamoDBAction_hashKeyField :: Lens' DynamoDBAction Text
dynamoDBAction_hashKeyField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Text
hashKeyField :: Text
$sel:hashKeyField:DynamoDBAction' :: DynamoDBAction -> Text
hashKeyField} -> Text
hashKeyField) (\s :: DynamoDBAction
s@DynamoDBAction' {} Text
a -> DynamoDBAction
s {$sel:hashKeyField:DynamoDBAction' :: Text
hashKeyField = Text
a} :: DynamoDBAction)

-- | The value of the hash key (also called the partition key).
dynamoDBAction_hashKeyValue :: Lens.Lens' DynamoDBAction Prelude.Text
dynamoDBAction_hashKeyValue :: Lens' DynamoDBAction Text
dynamoDBAction_hashKeyValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Text
hashKeyValue :: Text
$sel:hashKeyValue:DynamoDBAction' :: DynamoDBAction -> Text
hashKeyValue} -> Text
hashKeyValue) (\s :: DynamoDBAction
s@DynamoDBAction' {} Text
a -> DynamoDBAction
s {$sel:hashKeyValue:DynamoDBAction' :: Text
hashKeyValue = Text
a} :: DynamoDBAction)

-- | The name of the DynamoDB table. The @tableName@ value must match the
-- table name of the target DynamoDB table.
dynamoDBAction_tableName :: Lens.Lens' DynamoDBAction Prelude.Text
dynamoDBAction_tableName :: Lens' DynamoDBAction Text
dynamoDBAction_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBAction' {Text
tableName :: Text
$sel:tableName:DynamoDBAction' :: DynamoDBAction -> Text
tableName} -> Text
tableName) (\s :: DynamoDBAction
s@DynamoDBAction' {} Text
a -> DynamoDBAction
s {$sel:tableName:DynamoDBAction' :: Text
tableName = Text
a} :: DynamoDBAction)

instance Data.FromJSON DynamoDBAction where
  parseJSON :: Value -> Parser DynamoDBAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DynamoDBAction"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Payload
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> Text
-> DynamoDBAction
DynamoDBAction'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"hashKeyType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"operation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"payload")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"payloadField")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"rangeKeyField")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"rangeKeyType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"rangeKeyValue")
            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
"hashKeyField")
            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
"hashKeyValue")
            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
"tableName")
      )

instance Prelude.Hashable DynamoDBAction where
  hashWithSalt :: Int -> DynamoDBAction -> Int
hashWithSalt Int
_salt DynamoDBAction' {Maybe Text
Maybe Payload
Text
tableName :: Text
hashKeyValue :: Text
hashKeyField :: Text
rangeKeyValue :: Maybe Text
rangeKeyType :: Maybe Text
rangeKeyField :: Maybe Text
payloadField :: Maybe Text
payload :: Maybe Payload
operation :: Maybe Text
hashKeyType :: Maybe Text
$sel:tableName:DynamoDBAction' :: DynamoDBAction -> Text
$sel:hashKeyValue:DynamoDBAction' :: DynamoDBAction -> Text
$sel:hashKeyField:DynamoDBAction' :: DynamoDBAction -> Text
$sel:rangeKeyValue:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:rangeKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:rangeKeyField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:payloadField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:payload:DynamoDBAction' :: DynamoDBAction -> Maybe Payload
$sel:operation:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:hashKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hashKeyType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Payload
payload
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
payloadField
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rangeKeyField
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rangeKeyType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rangeKeyValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hashKeyField
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hashKeyValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName

instance Prelude.NFData DynamoDBAction where
  rnf :: DynamoDBAction -> ()
rnf DynamoDBAction' {Maybe Text
Maybe Payload
Text
tableName :: Text
hashKeyValue :: Text
hashKeyField :: Text
rangeKeyValue :: Maybe Text
rangeKeyType :: Maybe Text
rangeKeyField :: Maybe Text
payloadField :: Maybe Text
payload :: Maybe Payload
operation :: Maybe Text
hashKeyType :: Maybe Text
$sel:tableName:DynamoDBAction' :: DynamoDBAction -> Text
$sel:hashKeyValue:DynamoDBAction' :: DynamoDBAction -> Text
$sel:hashKeyField:DynamoDBAction' :: DynamoDBAction -> Text
$sel:rangeKeyValue:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:rangeKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:rangeKeyField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:payloadField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:payload:DynamoDBAction' :: DynamoDBAction -> Maybe Payload
$sel:operation:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:hashKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hashKeyType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Payload
payload
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
payloadField
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rangeKeyField
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rangeKeyType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rangeKeyValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hashKeyField
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hashKeyValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName

instance Data.ToJSON DynamoDBAction where
  toJSON :: DynamoDBAction -> Value
toJSON DynamoDBAction' {Maybe Text
Maybe Payload
Text
tableName :: Text
hashKeyValue :: Text
hashKeyField :: Text
rangeKeyValue :: Maybe Text
rangeKeyType :: Maybe Text
rangeKeyField :: Maybe Text
payloadField :: Maybe Text
payload :: Maybe Payload
operation :: Maybe Text
hashKeyType :: Maybe Text
$sel:tableName:DynamoDBAction' :: DynamoDBAction -> Text
$sel:hashKeyValue:DynamoDBAction' :: DynamoDBAction -> Text
$sel:hashKeyField:DynamoDBAction' :: DynamoDBAction -> Text
$sel:rangeKeyValue:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:rangeKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:rangeKeyField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:payloadField:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:payload:DynamoDBAction' :: DynamoDBAction -> Maybe Payload
$sel:operation:DynamoDBAction' :: DynamoDBAction -> Maybe Text
$sel:hashKeyType:DynamoDBAction' :: DynamoDBAction -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"hashKeyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
hashKeyType,
            (Key
"operation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
operation,
            (Key
"payload" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Payload
payload,
            (Key
"payloadField" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
payloadField,
            (Key
"rangeKeyField" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
rangeKeyField,
            (Key
"rangeKeyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
rangeKeyType,
            (Key
"rangeKeyValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
rangeKeyValue,
            forall a. a -> Maybe a
Prelude.Just (Key
"hashKeyField" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hashKeyField),
            forall a. a -> Maybe a
Prelude.Just (Key
"hashKeyValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hashKeyValue),
            forall a. a -> Maybe a
Prelude.Just (Key
"tableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName)
          ]
      )