{-# 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
/= :: DeleteItem -> DeleteItem -> Bool
$c/= :: DeleteItem -> DeleteItem -> Bool
== :: DeleteItem -> DeleteItem -> Bool
$c== :: 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
showList :: [DeleteItem] -> ShowS
$cshowList :: [DeleteItem] -> ShowS
show :: DeleteItem -> String
$cshow :: DeleteItem -> String
showsPrec :: Int -> DeleteItem -> ShowS
$cshowsPrec :: Int -> 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
readListPrec :: ReadPrec [DeleteItem]
$creadListPrec :: ReadPrec [DeleteItem]
readPrec :: ReadPrec DeleteItem
$creadPrec :: ReadPrec DeleteItem
readList :: ReadS [DeleteItem]
$creadList :: ReadS [DeleteItem]
readsPrec :: Int -> ReadS DeleteItem
$creadsPrec :: Int -> ReadS 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
min :: DeleteItem -> DeleteItem -> DeleteItem
$cmin :: DeleteItem -> DeleteItem -> DeleteItem
max :: DeleteItem -> DeleteItem -> DeleteItem
$cmax :: DeleteItem -> DeleteItem -> DeleteItem
>= :: DeleteItem -> DeleteItem -> Bool
$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
compare :: DeleteItem -> DeleteItem -> Ordering
$ccompare :: DeleteItem -> DeleteItem -> Ordering
$cp1Ord :: Eq 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
diRetMet :: ReturnItemCollectionMetrics
diRetCons :: ReturnConsumption
diReturn :: UpdateReturn
diExpect :: Conditions
diKey :: PrimaryKey
diTable :: Text
diRetMet :: DeleteItem -> ReturnItemCollectionMetrics
diRetCons :: DeleteItem -> ReturnConsumption
diReturn :: DeleteItem -> UpdateReturn
diExpect :: DeleteItem -> Conditions
diKey :: DeleteItem -> PrimaryKey
diTable :: DeleteItem -> Text
..} =
[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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
diTable
, Key
"Key" Key -> PrimaryKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PrimaryKey
diKey
, Key
"ReturnValues" Key -> UpdateReturn -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= UpdateReturn
diReturn
, Key
"ReturnConsumedCapacity" Key -> ReturnConsumption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ReturnConsumption
diRetCons
, Key
"ReturnItemCollectionMetrics" Key -> ReturnItemCollectionMetrics -> Pair
forall kv v. (KeyValue 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
/= :: DeleteItemResponse -> DeleteItemResponse -> Bool
$c/= :: DeleteItemResponse -> DeleteItemResponse -> Bool
== :: DeleteItemResponse -> DeleteItemResponse -> Bool
$c== :: 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
showList :: [DeleteItemResponse] -> ShowS
$cshowList :: [DeleteItemResponse] -> ShowS
show :: DeleteItemResponse -> String
$cshow :: DeleteItemResponse -> String
showsPrec :: Int -> DeleteItemResponse -> ShowS
$cshowsPrec :: Int -> 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
readListPrec :: ReadPrec [DeleteItemResponse]
$creadListPrec :: ReadPrec [DeleteItemResponse]
readPrec :: ReadPrec DeleteItemResponse
$creadPrec :: ReadPrec DeleteItemResponse
readList :: ReadS [DeleteItemResponse]
$creadList :: ReadS [DeleteItemResponse]
readsPrec :: Int -> ReadS DeleteItemResponse
$creadsPrec :: Int -> ReadS 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
min :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
$cmin :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
max :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
$cmax :: DeleteItemResponse -> DeleteItemResponse -> DeleteItemResponse
>= :: DeleteItemResponse -> DeleteItemResponse -> Bool
$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
compare :: DeleteItemResponse -> DeleteItemResponse -> Ordering
$ccompare :: DeleteItemResponse -> DeleteItemResponse -> Ordering
$cp1Ord :: Eq DeleteItemResponse
Ord)
instance Transaction DeleteItem DeleteItemResponse
instance SignQuery DeleteItem where
type ServiceConfiguration DeleteItem = DdbConfiguration
signQuery :: 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 (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 (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 (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)
forall (m :: * -> *) a. Monad m => a -> m a
return