{-# 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 {
DeleteItem -> Text
diTable :: T.Text
, DeleteItem -> PrimaryKey
diKey :: PrimaryKey
, DeleteItem -> Conditions
diExpect :: Conditions
, DeleteItem -> UpdateReturn
diReturn :: UpdateReturn
, DeleteItem -> ReturnConsumption
diRetCons :: ReturnConsumption
, DeleteItem -> ReturnItemCollectionMetrics
diRetMet :: ReturnItemCollectionMetrics
} deriving (DeleteItem -> DeleteItem -> Bool
(DeleteItem -> DeleteItem -> Bool)
-> (DeleteItem -> DeleteItem -> Bool) -> Eq DeleteItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteItem -> DeleteItem -> Bool
== :: DeleteItem -> DeleteItem -> Bool
$c/= :: DeleteItem -> DeleteItem -> Bool
/= :: DeleteItem -> DeleteItem -> Bool
Eq,Int -> DeleteItem -> ShowS
[DeleteItem] -> ShowS
DeleteItem -> String
(Int -> DeleteItem -> ShowS)
-> (DeleteItem -> String)
-> ([DeleteItem] -> ShowS)
-> Show DeleteItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteItem -> ShowS
showsPrec :: Int -> DeleteItem -> ShowS
$cshow :: DeleteItem -> String
show :: DeleteItem -> String
$cshowList :: [DeleteItem] -> ShowS
showList :: [DeleteItem] -> ShowS
Show,ReadPrec [DeleteItem]
ReadPrec DeleteItem
Int -> ReadS DeleteItem
ReadS [DeleteItem]
(Int -> ReadS DeleteItem)
-> ReadS [DeleteItem]
-> ReadPrec DeleteItem
-> ReadPrec [DeleteItem]
-> Read DeleteItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DeleteItem
readsPrec :: Int -> ReadS DeleteItem
$creadList :: ReadS [DeleteItem]
readList :: ReadS [DeleteItem]
$creadPrec :: ReadPrec DeleteItem
readPrec :: ReadPrec DeleteItem
$creadListPrec :: ReadPrec [DeleteItem]
readListPrec :: ReadPrec [DeleteItem]
Read,Eq DeleteItem
Eq DeleteItem =>
(DeleteItem -> DeleteItem -> Ordering)
-> (DeleteItem -> DeleteItem -> Bool)
-> (DeleteItem -> DeleteItem -> Bool)
-> (DeleteItem -> DeleteItem -> Bool)
-> (DeleteItem -> DeleteItem -> Bool)
-> (DeleteItem -> DeleteItem -> DeleteItem)
-> (DeleteItem -> DeleteItem -> DeleteItem)
-> Ord DeleteItem
DeleteItem -> DeleteItem -> Bool
DeleteItem -> DeleteItem -> Ordering
DeleteItem -> DeleteItem -> DeleteItem
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DeleteItem -> DeleteItem -> Ordering
compare :: DeleteItem -> DeleteItem -> Ordering
$c< :: DeleteItem -> DeleteItem -> Bool
< :: DeleteItem -> DeleteItem -> Bool
$c<= :: DeleteItem -> DeleteItem -> Bool
<= :: DeleteItem -> DeleteItem -> Bool
$c> :: DeleteItem -> DeleteItem -> Bool
> :: DeleteItem -> DeleteItem -> Bool
$c>= :: DeleteItem -> DeleteItem -> Bool
>= :: DeleteItem -> DeleteItem -> Bool
$cmax :: DeleteItem -> DeleteItem -> DeleteItem
max :: DeleteItem -> DeleteItem -> DeleteItem
$cmin :: DeleteItem -> DeleteItem -> DeleteItem
min :: DeleteItem -> DeleteItem -> DeleteItem
Ord)
deleteItem :: T.Text
-> PrimaryKey
-> DeleteItem
deleteItem :: Text -> PrimaryKey -> DeleteItem
deleteItem Text
tn PrimaryKey
key = Text
-> PrimaryKey
-> Conditions
-> UpdateReturn
-> ReturnConsumption
-> ReturnItemCollectionMetrics
-> DeleteItem
DeleteItem Text
tn PrimaryKey
key Conditions
forall a. Default a => a
def UpdateReturn
forall a. Default a => a
def ReturnConsumption
forall a. Default a => a
def ReturnItemCollectionMetrics
forall a. Default a => a
def
instance ToJSON DeleteItem where
toJSON :: DeleteItem -> Value
toJSON DeleteItem{Text
UpdateReturn
ReturnItemCollectionMetrics
ReturnConsumption
Conditions
PrimaryKey
diTable :: DeleteItem -> Text
diKey :: DeleteItem -> PrimaryKey
diExpect :: DeleteItem -> Conditions
diReturn :: DeleteItem -> UpdateReturn
diRetCons :: DeleteItem -> ReturnConsumption
diRetMet :: DeleteItem -> ReturnItemCollectionMetrics
diTable :: Text
diKey :: PrimaryKey
diExpect :: Conditions
diReturn :: UpdateReturn
diRetCons :: ReturnConsumption
diRetMet :: ReturnItemCollectionMetrics
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ Conditions -> [Pair]
expectsJson Conditions
diExpect [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
[ Key
"TableName" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
diTable
, Key
"Key" Key -> PrimaryKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PrimaryKey
diKey
, Key
"ReturnValues" Key -> UpdateReturn -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= UpdateReturn
diReturn
, Key
"ReturnConsumedCapacity" Key -> ReturnConsumption -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReturnConsumption
diRetCons
, Key
"ReturnItemCollectionMetrics" Key -> ReturnItemCollectionMetrics -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReturnItemCollectionMetrics
diRetMet
]
data DeleteItemResponse = DeleteItemResponse {
DeleteItemResponse -> Maybe Item
dirAttrs :: Maybe Item
, DeleteItemResponse -> Maybe ConsumedCapacity
dirConsumed :: Maybe ConsumedCapacity
, DeleteItemResponse -> Maybe ItemCollectionMetrics
dirColMet :: Maybe ItemCollectionMetrics
} deriving (DeleteItemResponse -> DeleteItemResponse -> Bool
(DeleteItemResponse -> DeleteItemResponse -> Bool)
-> (DeleteItemResponse -> DeleteItemResponse -> Bool)
-> Eq DeleteItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteItemResponse -> DeleteItemResponse -> Bool
== :: DeleteItemResponse -> DeleteItemResponse -> Bool
$c/= :: DeleteItemResponse -> DeleteItemResponse -> Bool
/= :: DeleteItemResponse -> DeleteItemResponse -> Bool
Eq,Int -> DeleteItemResponse -> ShowS
[DeleteItemResponse] -> ShowS
DeleteItemResponse -> String
(Int -> DeleteItemResponse -> ShowS)
-> (DeleteItemResponse -> String)
-> ([DeleteItemResponse] -> ShowS)
-> Show DeleteItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteItemResponse -> ShowS
showsPrec :: Int -> DeleteItemResponse -> ShowS
$cshow :: DeleteItemResponse -> String
show :: DeleteItemResponse -> String
$cshowList :: [DeleteItemResponse] -> ShowS
showList :: [DeleteItemResponse] -> ShowS
Show,ReadPrec [DeleteItemResponse]
ReadPrec DeleteItemResponse
Int -> ReadS DeleteItemResponse
ReadS [DeleteItemResponse]
(Int -> ReadS DeleteItemResponse)
-> ReadS [DeleteItemResponse]
-> ReadPrec DeleteItemResponse
-> ReadPrec [DeleteItemResponse]
-> Read DeleteItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DeleteItemResponse
readsPrec :: Int -> ReadS DeleteItemResponse
$creadList :: ReadS [DeleteItemResponse]
readList :: ReadS [DeleteItemResponse]
$creadPrec :: ReadPrec DeleteItemResponse
readPrec :: ReadPrec DeleteItemResponse
$creadListPrec :: ReadPrec [DeleteItemResponse]
readListPrec :: ReadPrec [DeleteItemResponse]
Read,Eq DeleteItemResponse
Eq DeleteItemResponse =>
(DeleteItemResponse -> DeleteItemResponse -> Ordering)
-> (DeleteItemResponse -> DeleteItemResponse -> Bool)
-> (DeleteItemResponse -> DeleteItemResponse -> Bool)
-> (DeleteItemResponse -> DeleteItemResponse -> Bool)
-> (DeleteItemResponse -> DeleteItemResponse -> Bool)
-> (DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse)
-> (DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse)
-> Ord DeleteItemResponse
DeleteItemResponse -> DeleteItemResponse -> Bool
DeleteItemResponse -> DeleteItemResponse -> Ordering
DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DeleteItemResponse -> DeleteItemResponse -> Ordering
compare :: DeleteItemResponse -> DeleteItemResponse -> Ordering
$c< :: DeleteItemResponse -> DeleteItemResponse -> Bool
< :: DeleteItemResponse -> DeleteItemResponse -> Bool
$c<= :: DeleteItemResponse -> DeleteItemResponse -> Bool
<= :: DeleteItemResponse -> DeleteItemResponse -> Bool
$c> :: DeleteItemResponse -> DeleteItemResponse -> Bool
> :: DeleteItemResponse -> DeleteItemResponse -> Bool
$c>= :: DeleteItemResponse -> DeleteItemResponse -> Bool
>= :: DeleteItemResponse -> DeleteItemResponse -> Bool
$cmax :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
max :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
$cmin :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
min :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
Ord)
instance Transaction DeleteItem DeleteItemResponse
instance SignQuery DeleteItem where
type ServiceConfiguration DeleteItem = DdbConfiguration
signQuery :: forall queryType.
DeleteItem
-> ServiceConfiguration DeleteItem queryType
-> SignatureData
-> SignedQuery
signQuery DeleteItem
gi = ByteString
-> DeleteItem
-> DdbConfiguration queryType
-> SignatureData
-> SignedQuery
forall a qt.
ToJSON a =>
ByteString
-> a -> DdbConfiguration qt -> SignatureData -> SignedQuery
ddbSignQuery ByteString
"DeleteItem" DeleteItem
gi
instance FromJSON DeleteItemResponse where
parseJSON :: Value -> Parser DeleteItemResponse
parseJSON (Object Object
v) = Maybe Item
-> Maybe ConsumedCapacity
-> Maybe ItemCollectionMetrics
-> DeleteItemResponse
DeleteItemResponse
(Maybe Item
-> Maybe ConsumedCapacity
-> Maybe ItemCollectionMetrics
-> DeleteItemResponse)
-> Parser (Maybe Item)
-> Parser
(Maybe ConsumedCapacity
-> Maybe ItemCollectionMetrics -> DeleteItemResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Item)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"Attributes"
Parser
(Maybe ConsumedCapacity
-> Maybe ItemCollectionMetrics -> DeleteItemResponse)
-> Parser (Maybe ConsumedCapacity)
-> Parser (Maybe ItemCollectionMetrics -> DeleteItemResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe ConsumedCapacity)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"ConsumedCapacity"
Parser (Maybe ItemCollectionMetrics -> DeleteItemResponse)
-> Parser (Maybe ItemCollectionMetrics)
-> Parser DeleteItemResponse
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe ItemCollectionMetrics)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"ItemCollectionMetrics"
parseJSON Value
_ = String -> Parser DeleteItemResponse
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"DeleteItemResponse must be an object."
instance ResponseConsumer r DeleteItemResponse where
type ResponseMetadata DeleteItemResponse = DdbResponse
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata DeleteItemResponse)
-> HTTPResponseConsumer DeleteItemResponse
responseConsumer Request
_ r
_ IORef (ResponseMetadata DeleteItemResponse)
ref Response (ConduitM () ByteString (ResourceT IO) ())
resp = IORef DdbResponse -> HTTPResponseConsumer DeleteItemResponse
forall a. FromJSON a => IORef DdbResponse -> HTTPResponseConsumer a
ddbResponseConsumer IORef (ResponseMetadata DeleteItemResponse)
IORef DdbResponse
ref Response (ConduitM () ByteString (ResourceT IO) ())
resp
instance AsMemoryResponse DeleteItemResponse where
type MemoryResponse DeleteItemResponse = DeleteItemResponse
loadToMemory :: DeleteItemResponse
-> ResourceT IO (MemoryResponse DeleteItemResponse)
loadToMemory = DeleteItemResponse
-> ResourceT IO (MemoryResponse DeleteItemResponse)
DeleteItemResponse -> ResourceT IO DeleteItemResponse
forall a. a -> ResourceT IO a
forall (m :: * -> *) a. Monad m => a -> m a
return