{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Aws.DynamoDb.Commands.DeleteItem where
import Control.Applicative
import Data.Aeson
import Data.Default
import qualified Data.Text as T
import Prelude
import Aws.Core
import Aws.DynamoDb.Core
data DeleteItem = DeleteItem {
diTable :: T.Text
, diKey :: PrimaryKey
, diExpect :: Conditions
, diReturn :: UpdateReturn
, diRetCons :: ReturnConsumption
, diRetMet :: ReturnItemCollectionMetrics
} deriving (Eq,Show,Read,Ord)
deleteItem :: T.Text
-> PrimaryKey
-> DeleteItem
deleteItem tn key = DeleteItem tn key def def def def
instance ToJSON DeleteItem where
toJSON DeleteItem{..} =
object $ expectsJson diExpect ++
[ "TableName" .= diTable
, "Key" .= diKey
, "ReturnValues" .= diReturn
, "ReturnConsumedCapacity" .= diRetCons
, "ReturnItemCollectionMetrics" .= diRetMet
]
data DeleteItemResponse = DeleteItemResponse {
dirAttrs :: Maybe Item
, dirConsumed :: Maybe ConsumedCapacity
, dirColMet :: Maybe ItemCollectionMetrics
} deriving (Eq,Show,Read,Ord)
instance Transaction DeleteItem DeleteItemResponse
instance SignQuery DeleteItem where
type ServiceConfiguration DeleteItem = DdbConfiguration
signQuery gi = ddbSignQuery "DeleteItem" gi
instance FromJSON DeleteItemResponse where
parseJSON (Object v) = DeleteItemResponse
<$> v .:? "Attributes"
<*> v .:? "ConsumedCapacity"
<*> v .:? "ItemCollectionMetrics"
parseJSON _ = fail "DeleteItemResponse must be an object."
instance ResponseConsumer r DeleteItemResponse where
type ResponseMetadata DeleteItemResponse = DdbResponse
responseConsumer _ _ ref resp = ddbResponseConsumer ref resp
instance AsMemoryResponse DeleteItemResponse where
type MemoryResponse DeleteItemResponse = DeleteItemResponse
loadToMemory = return