{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Aws.DynamoDb.Commands.BatchGetItem where
import Control.Applicative
import Data.Aeson
import Data.Default
import qualified Data.HashMap.Strict as HM
import qualified Data.Text as T
import Prelude
import Aws.Core
import Aws.DynamoDb.Core
import Aws.DynamoDb.Commands.GetItem
data GetRequestItem = GetRequestItem{
GetRequestItem -> Maybe Text
griProjExpr :: Maybe T.Text
, GetRequestItem -> Bool
griConsistent ::Bool
, GetRequestItem -> [PrimaryKey]
griKeys :: [PrimaryKey]
} deriving (GetRequestItem -> GetRequestItem -> Bool
(GetRequestItem -> GetRequestItem -> Bool)
-> (GetRequestItem -> GetRequestItem -> Bool) -> Eq GetRequestItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRequestItem -> GetRequestItem -> Bool
$c/= :: GetRequestItem -> GetRequestItem -> Bool
== :: GetRequestItem -> GetRequestItem -> Bool
$c== :: GetRequestItem -> GetRequestItem -> Bool
Eq,Int -> GetRequestItem -> ShowS
[GetRequestItem] -> ShowS
GetRequestItem -> String
(Int -> GetRequestItem -> ShowS)
-> (GetRequestItem -> String)
-> ([GetRequestItem] -> ShowS)
-> Show GetRequestItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRequestItem] -> ShowS
$cshowList :: [GetRequestItem] -> ShowS
show :: GetRequestItem -> String
$cshow :: GetRequestItem -> String
showsPrec :: Int -> GetRequestItem -> ShowS
$cshowsPrec :: Int -> GetRequestItem -> ShowS
Show,ReadPrec [GetRequestItem]
ReadPrec GetRequestItem
Int -> ReadS GetRequestItem
ReadS [GetRequestItem]
(Int -> ReadS GetRequestItem)
-> ReadS [GetRequestItem]
-> ReadPrec GetRequestItem
-> ReadPrec [GetRequestItem]
-> Read GetRequestItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRequestItem]
$creadListPrec :: ReadPrec [GetRequestItem]
readPrec :: ReadPrec GetRequestItem
$creadPrec :: ReadPrec GetRequestItem
readList :: ReadS [GetRequestItem]
$creadList :: ReadS [GetRequestItem]
readsPrec :: Int -> ReadS GetRequestItem
$creadsPrec :: Int -> ReadS GetRequestItem
Read,Eq GetRequestItem
Eq GetRequestItem
-> (GetRequestItem -> GetRequestItem -> Ordering)
-> (GetRequestItem -> GetRequestItem -> Bool)
-> (GetRequestItem -> GetRequestItem -> Bool)
-> (GetRequestItem -> GetRequestItem -> Bool)
-> (GetRequestItem -> GetRequestItem -> Bool)
-> (GetRequestItem -> GetRequestItem -> GetRequestItem)
-> (GetRequestItem -> GetRequestItem -> GetRequestItem)
-> Ord GetRequestItem
GetRequestItem -> GetRequestItem -> Bool
GetRequestItem -> GetRequestItem -> Ordering
GetRequestItem -> GetRequestItem -> GetRequestItem
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 :: GetRequestItem -> GetRequestItem -> GetRequestItem
$cmin :: GetRequestItem -> GetRequestItem -> GetRequestItem
max :: GetRequestItem -> GetRequestItem -> GetRequestItem
$cmax :: GetRequestItem -> GetRequestItem -> GetRequestItem
>= :: GetRequestItem -> GetRequestItem -> Bool
$c>= :: GetRequestItem -> GetRequestItem -> Bool
> :: GetRequestItem -> GetRequestItem -> Bool
$c> :: GetRequestItem -> GetRequestItem -> Bool
<= :: GetRequestItem -> GetRequestItem -> Bool
$c<= :: GetRequestItem -> GetRequestItem -> Bool
< :: GetRequestItem -> GetRequestItem -> Bool
$c< :: GetRequestItem -> GetRequestItem -> Bool
compare :: GetRequestItem -> GetRequestItem -> Ordering
$ccompare :: GetRequestItem -> GetRequestItem -> Ordering
$cp1Ord :: Eq GetRequestItem
Ord)
data BatchGetItem = BatchGetItem {
BatchGetItem -> [(Text, GetRequestItem)]
bgRequests :: [(T.Text,GetRequestItem)]
, BatchGetItem -> ReturnConsumption
bgRetCons :: ReturnConsumption
} deriving (BatchGetItem -> BatchGetItem -> Bool
(BatchGetItem -> BatchGetItem -> Bool)
-> (BatchGetItem -> BatchGetItem -> Bool) -> Eq BatchGetItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetItem -> BatchGetItem -> Bool
$c/= :: BatchGetItem -> BatchGetItem -> Bool
== :: BatchGetItem -> BatchGetItem -> Bool
$c== :: BatchGetItem -> BatchGetItem -> Bool
Eq,Int -> BatchGetItem -> ShowS
[BatchGetItem] -> ShowS
BatchGetItem -> String
(Int -> BatchGetItem -> ShowS)
-> (BatchGetItem -> String)
-> ([BatchGetItem] -> ShowS)
-> Show BatchGetItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetItem] -> ShowS
$cshowList :: [BatchGetItem] -> ShowS
show :: BatchGetItem -> String
$cshow :: BatchGetItem -> String
showsPrec :: Int -> BatchGetItem -> ShowS
$cshowsPrec :: Int -> BatchGetItem -> ShowS
Show,ReadPrec [BatchGetItem]
ReadPrec BatchGetItem
Int -> ReadS BatchGetItem
ReadS [BatchGetItem]
(Int -> ReadS BatchGetItem)
-> ReadS [BatchGetItem]
-> ReadPrec BatchGetItem
-> ReadPrec [BatchGetItem]
-> Read BatchGetItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetItem]
$creadListPrec :: ReadPrec [BatchGetItem]
readPrec :: ReadPrec BatchGetItem
$creadPrec :: ReadPrec BatchGetItem
readList :: ReadS [BatchGetItem]
$creadList :: ReadS [BatchGetItem]
readsPrec :: Int -> ReadS BatchGetItem
$creadsPrec :: Int -> ReadS BatchGetItem
Read,Eq BatchGetItem
Eq BatchGetItem
-> (BatchGetItem -> BatchGetItem -> Ordering)
-> (BatchGetItem -> BatchGetItem -> Bool)
-> (BatchGetItem -> BatchGetItem -> Bool)
-> (BatchGetItem -> BatchGetItem -> Bool)
-> (BatchGetItem -> BatchGetItem -> Bool)
-> (BatchGetItem -> BatchGetItem -> BatchGetItem)
-> (BatchGetItem -> BatchGetItem -> BatchGetItem)
-> Ord BatchGetItem
BatchGetItem -> BatchGetItem -> Bool
BatchGetItem -> BatchGetItem -> Ordering
BatchGetItem -> BatchGetItem -> BatchGetItem
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 :: BatchGetItem -> BatchGetItem -> BatchGetItem
$cmin :: BatchGetItem -> BatchGetItem -> BatchGetItem
max :: BatchGetItem -> BatchGetItem -> BatchGetItem
$cmax :: BatchGetItem -> BatchGetItem -> BatchGetItem
>= :: BatchGetItem -> BatchGetItem -> Bool
$c>= :: BatchGetItem -> BatchGetItem -> Bool
> :: BatchGetItem -> BatchGetItem -> Bool
$c> :: BatchGetItem -> BatchGetItem -> Bool
<= :: BatchGetItem -> BatchGetItem -> Bool
$c<= :: BatchGetItem -> BatchGetItem -> Bool
< :: BatchGetItem -> BatchGetItem -> Bool
$c< :: BatchGetItem -> BatchGetItem -> Bool
compare :: BatchGetItem -> BatchGetItem -> Ordering
$ccompare :: BatchGetItem -> BatchGetItem -> Ordering
$cp1Ord :: Eq BatchGetItem
Ord)
batchGetRequestItem :: Maybe T.Text
-> Bool
-> [PrimaryKey]
-> GetRequestItem
batchGetRequestItem :: Maybe Text -> Bool -> [PrimaryKey] -> GetRequestItem
batchGetRequestItem Maybe Text
expr Bool
consistent [PrimaryKey]
keys = Maybe Text -> Bool -> [PrimaryKey] -> GetRequestItem
GetRequestItem Maybe Text
expr Bool
consistent [PrimaryKey]
keys
toBatchGet :: [GetItem] -> BatchGetItem
toBatchGet :: [GetItem] -> BatchGetItem
toBatchGet [GetItem]
gs = [(Text, GetRequestItem)] -> ReturnConsumption -> BatchGetItem
BatchGetItem ([GetItem] -> [(Text, GetRequestItem)]
convert [GetItem]
gs) ReturnConsumption
forall a. Default a => a
def
where
groupItems :: [GetItem]-> HM.HashMap T.Text [GetItem] -> HM.HashMap T.Text [GetItem]
groupItems :: [GetItem] -> HashMap Text [GetItem] -> HashMap Text [GetItem]
groupItems [] HashMap Text [GetItem]
hm = HashMap Text [GetItem]
hm
groupItems (GetItem
x:[GetItem]
xs) HashMap Text [GetItem]
hm = let key :: Text
key = GetItem -> Text
giTableName GetItem
x
in [GetItem] -> HashMap Text [GetItem] -> HashMap Text [GetItem]
groupItems [GetItem]
xs (Text
-> [GetItem] -> HashMap Text [GetItem] -> HashMap Text [GetItem]
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
HM.insert Text
key (GetItem
x GetItem -> [GetItem] -> [GetItem]
forall a. a -> [a] -> [a]
: ([GetItem] -> Text -> HashMap Text [GetItem] -> [GetItem]
forall k v. (Eq k, Hashable k) => v -> k -> HashMap k v -> v
HM.lookupDefault [] Text
key HashMap Text [GetItem]
hm)) HashMap Text [GetItem]
hm)
convert :: [GetItem] -> [(T.Text,GetRequestItem)]
convert :: [GetItem] -> [(Text, GetRequestItem)]
convert [GetItem]
gs' = let l :: [(Text, [GetItem])]
l = HashMap Text [GetItem] -> [(Text, [GetItem])]
forall k v. HashMap k v -> [(k, v)]
HM.toList (HashMap Text [GetItem] -> [(Text, [GetItem])])
-> HashMap Text [GetItem] -> [(Text, [GetItem])]
forall a b. (a -> b) -> a -> b
$ [GetItem] -> HashMap Text [GetItem] -> HashMap Text [GetItem]
groupItems [GetItem]
gs' HashMap Text [GetItem]
forall k v. HashMap k v
HM.empty
in ((Text, [GetItem]) -> (Text, GetRequestItem))
-> [(Text, [GetItem])] -> [(Text, GetRequestItem)]
forall a b. (a -> b) -> [a] -> [b]
map (\(Text
table,items :: [GetItem]
items@(GetItem
i:[GetItem]
_)) ->(Text
table,Maybe Text -> Bool -> [PrimaryKey] -> GetRequestItem
GetRequestItem
(Text -> [Text] -> Text
T.intercalate Text
"," ([Text] -> Text) -> Maybe [Text] -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GetItem -> Maybe [Text]
giAttrs GetItem
i)
(GetItem -> Bool
giConsistent GetItem
i)
((GetItem -> PrimaryKey) -> [GetItem] -> [PrimaryKey]
forall a b. (a -> b) -> [a] -> [b]
map GetItem -> PrimaryKey
giKey [GetItem]
items)) ) [(Text, [GetItem])]
l
batchGetItem :: [(T.Text, GetRequestItem)]
-> BatchGetItem
batchGetItem :: [(Text, GetRequestItem)] -> BatchGetItem
batchGetItem [(Text, GetRequestItem)]
reqs = [(Text, GetRequestItem)] -> ReturnConsumption -> BatchGetItem
BatchGetItem [(Text, GetRequestItem)]
reqs ReturnConsumption
forall a. Default a => a
def
instance ToJSON GetRequestItem where
toJSON :: GetRequestItem -> Value
toJSON GetRequestItem{Bool
[PrimaryKey]
Maybe Text
griKeys :: [PrimaryKey]
griConsistent :: Bool
griProjExpr :: Maybe Text
griKeys :: GetRequestItem -> [PrimaryKey]
griConsistent :: GetRequestItem -> Bool
griProjExpr :: GetRequestItem -> Maybe Text
..} =
([Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (Pair -> [Pair]
forall (m :: * -> *) a. Monad m => a -> m a
return (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Key
"ProjectionExpression" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=)) Maybe Text
griProjExpr [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
[Key
"ConsistentRead" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
griConsistent
, Key
"Keys" Key -> [PrimaryKey] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [PrimaryKey]
griKeys])
instance ToJSON BatchGetItem where
toJSON :: BatchGetItem -> Value
toJSON BatchGetItem{[(Text, GetRequestItem)]
ReturnConsumption
bgRetCons :: ReturnConsumption
bgRequests :: [(Text, GetRequestItem)]
bgRetCons :: BatchGetItem -> ReturnConsumption
bgRequests :: BatchGetItem -> [(Text, GetRequestItem)]
..} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[ Key
"RequestItems" Key -> HashMap Text GetRequestItem -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Text, GetRequestItem)] -> HashMap Text GetRequestItem
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HM.fromList [(Text, GetRequestItem)]
bgRequests
, Key
"ReturnConsumedCapacity" Key -> ReturnConsumption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ReturnConsumption
bgRetCons
]
instance FromJSON GetRequestItem where
parseJSON :: Value -> Parser GetRequestItem
parseJSON (Object Object
p) = do
Maybe Text -> Bool -> [PrimaryKey] -> GetRequestItem
GetRequestItem (Maybe Text -> Bool -> [PrimaryKey] -> GetRequestItem)
-> Parser (Maybe Text)
-> Parser (Bool -> [PrimaryKey] -> GetRequestItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
p Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"ProjectionExpression"
Parser (Bool -> [PrimaryKey] -> GetRequestItem)
-> Parser Bool -> Parser ([PrimaryKey] -> GetRequestItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
p Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"ConsistentRead"
Parser ([PrimaryKey] -> GetRequestItem)
-> Parser [PrimaryKey] -> Parser GetRequestItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
p Object -> Key -> Parser [PrimaryKey]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"Keys"
parseJSON Value
_ = String -> Parser GetRequestItem
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"unable to parse GetRequestItem"
data BatchGetItemResponse = BatchGetItemResponse {
BatchGetItemResponse -> [(Text, [Item])]
bgResponses :: [(T.Text, [Item])]
, BatchGetItemResponse -> Maybe [(Text, GetRequestItem)]
bgUnprocessed :: Maybe [(T.Text,GetRequestItem)]
, BatchGetItemResponse -> Maybe ConsumedCapacity
bgConsumed :: Maybe ConsumedCapacity
} deriving (BatchGetItemResponse -> BatchGetItemResponse -> Bool
(BatchGetItemResponse -> BatchGetItemResponse -> Bool)
-> (BatchGetItemResponse -> BatchGetItemResponse -> Bool)
-> Eq BatchGetItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
$c/= :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
== :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
$c== :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
Eq,Int -> BatchGetItemResponse -> ShowS
[BatchGetItemResponse] -> ShowS
BatchGetItemResponse -> String
(Int -> BatchGetItemResponse -> ShowS)
-> (BatchGetItemResponse -> String)
-> ([BatchGetItemResponse] -> ShowS)
-> Show BatchGetItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetItemResponse] -> ShowS
$cshowList :: [BatchGetItemResponse] -> ShowS
show :: BatchGetItemResponse -> String
$cshow :: BatchGetItemResponse -> String
showsPrec :: Int -> BatchGetItemResponse -> ShowS
$cshowsPrec :: Int -> BatchGetItemResponse -> ShowS
Show,ReadPrec [BatchGetItemResponse]
ReadPrec BatchGetItemResponse
Int -> ReadS BatchGetItemResponse
ReadS [BatchGetItemResponse]
(Int -> ReadS BatchGetItemResponse)
-> ReadS [BatchGetItemResponse]
-> ReadPrec BatchGetItemResponse
-> ReadPrec [BatchGetItemResponse]
-> Read BatchGetItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetItemResponse]
$creadListPrec :: ReadPrec [BatchGetItemResponse]
readPrec :: ReadPrec BatchGetItemResponse
$creadPrec :: ReadPrec BatchGetItemResponse
readList :: ReadS [BatchGetItemResponse]
$creadList :: ReadS [BatchGetItemResponse]
readsPrec :: Int -> ReadS BatchGetItemResponse
$creadsPrec :: Int -> ReadS BatchGetItemResponse
Read,Eq BatchGetItemResponse
Eq BatchGetItemResponse
-> (BatchGetItemResponse -> BatchGetItemResponse -> Ordering)
-> (BatchGetItemResponse -> BatchGetItemResponse -> Bool)
-> (BatchGetItemResponse -> BatchGetItemResponse -> Bool)
-> (BatchGetItemResponse -> BatchGetItemResponse -> Bool)
-> (BatchGetItemResponse -> BatchGetItemResponse -> Bool)
-> (BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse)
-> (BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse)
-> Ord BatchGetItemResponse
BatchGetItemResponse -> BatchGetItemResponse -> Bool
BatchGetItemResponse -> BatchGetItemResponse -> Ordering
BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse
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 :: BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse
$cmin :: BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse
max :: BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse
$cmax :: BatchGetItemResponse
-> BatchGetItemResponse -> BatchGetItemResponse
>= :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
$c>= :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
> :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
$c> :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
<= :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
$c<= :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
< :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
$c< :: BatchGetItemResponse -> BatchGetItemResponse -> Bool
compare :: BatchGetItemResponse -> BatchGetItemResponse -> Ordering
$ccompare :: BatchGetItemResponse -> BatchGetItemResponse -> Ordering
$cp1Ord :: Eq BatchGetItemResponse
Ord)
instance Transaction BatchGetItem BatchGetItemResponse
instance SignQuery BatchGetItem where
type ServiceConfiguration BatchGetItem = DdbConfiguration
signQuery :: BatchGetItem
-> ServiceConfiguration BatchGetItem queryType
-> SignatureData
-> SignedQuery
signQuery BatchGetItem
gi = ByteString
-> BatchGetItem
-> DdbConfiguration queryType
-> SignatureData
-> SignedQuery
forall a qt.
ToJSON a =>
ByteString
-> a -> DdbConfiguration qt -> SignatureData -> SignedQuery
ddbSignQuery ByteString
"BatchGetItem" BatchGetItem
gi
instance FromJSON BatchGetItemResponse where
parseJSON :: Value -> Parser BatchGetItemResponse
parseJSON (Object Object
v) = [(Text, [Item])]
-> Maybe [(Text, GetRequestItem)]
-> Maybe ConsumedCapacity
-> BatchGetItemResponse
BatchGetItemResponse
([(Text, [Item])]
-> Maybe [(Text, GetRequestItem)]
-> Maybe ConsumedCapacity
-> BatchGetItemResponse)
-> Parser [(Text, [Item])]
-> Parser
(Maybe [(Text, GetRequestItem)]
-> Maybe ConsumedCapacity -> BatchGetItemResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (HashMap Text [Item] -> [(Text, [Item])]
forall k v. HashMap k v -> [(k, v)]
HM.toList (HashMap Text [Item] -> [(Text, [Item])])
-> Parser (HashMap Text [Item]) -> Parser [(Text, [Item])]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Object
v Object -> Key -> Parser (HashMap Text [Item])
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"Responses"))
Parser
(Maybe [(Text, GetRequestItem)]
-> Maybe ConsumedCapacity -> BatchGetItemResponse)
-> Parser (Maybe [(Text, GetRequestItem)])
-> Parser (Maybe ConsumedCapacity -> BatchGetItemResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe [(Text, GetRequestItem)])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"UnprocessedItems"
Parser (Maybe ConsumedCapacity -> BatchGetItemResponse)
-> Parser (Maybe ConsumedCapacity) -> Parser BatchGetItemResponse
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"
parseJSON Value
_ = String -> Parser BatchGetItemResponse
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"BatchGetItemResponse must be an object."
instance ResponseConsumer r BatchGetItemResponse where
type ResponseMetadata BatchGetItemResponse = DdbResponse
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata BatchGetItemResponse)
-> HTTPResponseConsumer BatchGetItemResponse
responseConsumer Request
_ r
_ IORef (ResponseMetadata BatchGetItemResponse)
ref Response (ConduitM () ByteString (ResourceT IO) ())
resp = IORef DdbResponse -> HTTPResponseConsumer BatchGetItemResponse
forall a. FromJSON a => IORef DdbResponse -> HTTPResponseConsumer a
ddbResponseConsumer IORef (ResponseMetadata BatchGetItemResponse)
IORef DdbResponse
ref Response (ConduitM () ByteString (ResourceT IO) ())
resp
instance AsMemoryResponse BatchGetItemResponse where
type MemoryResponse BatchGetItemResponse = BatchGetItemResponse
loadToMemory :: BatchGetItemResponse
-> ResourceT IO (MemoryResponse BatchGetItemResponse)
loadToMemory = BatchGetItemResponse
-> ResourceT IO (MemoryResponse BatchGetItemResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return