module Aws.DynamoDb.Commands.DeleteItem where
import Control.Applicative
import Data.Aeson
import Data.Default
import qualified Data.Text as T
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