    {-# LANGUAGE DeriveDataTypeable        #-}
    {-# LANGUAGE FlexibleContexts          #-}
    {-# LANGUAGE FlexibleInstances         #-}
    {-# LANGUAGE MultiParamTypeClasses     #-}
    {-# LANGUAGE NoMonomorphismRestriction #-}
    {-# LANGUAGE OverloadedStrings         #-}
    {-# LANGUAGE RecordWildCards           #-}
    {-# LANGUAGE ScopedTypeVariables       #-}
    {-# LANGUAGE TypeFamilies              #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  Aws.DynamoDb.Commands.BatchWriteItem
    -- Copyright   :  Soostone Inc
    -- License     :  BSD3
    --
    -- Maintainer  :  Justin Dawson <jtdawso@gmail.com>
    -- Stability   :  experimental
    --
    -- @http:\/\/docs.aws.amazon.com\/amazondynamodb\/latest\/APIReference\/API_BatchWriteItem.html@
    ----------------------------------------------------------------------------

    module Aws.DynamoDb.Commands.BatchWriteItem where

    -------------------------------------------------------------------------------
    import           Control.Applicative
    import           Data.Aeson
    import           Data.Default
    import           Data.Foldable (asum)
    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.PutItem
    import           Aws.DynamoDb.Commands.DeleteItem
    -------------------------------------------------------------------------------

    data Request = PutRequest { Request -> Item
    prItem :: Item }
                 | DeleteRequest {Request -> PrimaryKey
    drKey :: PrimaryKey}
         deriving (Request -> Request -> Bool
    (Request -> Request -> Bool)
    -> (Request -> Request -> Bool) -> Eq Request
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Request -> Request -> Bool
    == :: Request -> Request -> Bool
    $c/= :: Request -> Request -> Bool
    /= :: Request -> Request -> Bool
    Eq,Int -> Request -> ShowS
    [Request] -> ShowS
    Request -> String
    (Int -> Request -> ShowS)
    -> (Request -> String) -> ([Request] -> ShowS) -> Show Request
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Request -> ShowS
    showsPrec :: Int -> Request -> ShowS
    $cshow :: Request -> String
    show :: Request -> String
    $cshowList :: [Request] -> ShowS
    showList :: [Request] -> ShowS
    Show,ReadPrec [Request]
    ReadPrec Request
    Int -> ReadS Request
    ReadS [Request]
    (Int -> ReadS Request)
    -> ReadS [Request]
    -> ReadPrec Request
    -> ReadPrec [Request]
    -> Read Request
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Request
    readsPrec :: Int -> ReadS Request
    $creadList :: ReadS [Request]
    readList :: ReadS [Request]
    $creadPrec :: ReadPrec Request
    readPrec :: ReadPrec Request
    $creadListPrec :: ReadPrec [Request]
    readListPrec :: ReadPrec [Request]
    Read,Eq Request
    Eq Request =>
    (Request -> Request -> Ordering)
    -> (Request -> Request -> Bool)
    -> (Request -> Request -> Bool)
    -> (Request -> Request -> Bool)
    -> (Request -> Request -> Bool)
    -> (Request -> Request -> Request)
    -> (Request -> Request -> Request)
    -> Ord Request
    Request -> Request -> Bool
    Request -> Request -> Ordering
    Request -> Request -> Request
    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 :: Request -> Request -> Ordering
    compare :: Request -> Request -> Ordering
    $c< :: Request -> Request -> Bool
    < :: Request -> Request -> Bool
    $c<= :: Request -> Request -> Bool
    <= :: Request -> Request -> Bool
    $c> :: Request -> Request -> Bool
    > :: Request -> Request -> Bool
    $c>= :: Request -> Request -> Bool
    >= :: Request -> Request -> Bool
    $cmax :: Request -> Request -> Request
    max :: Request -> Request -> Request
    $cmin :: Request -> Request -> Request
    min :: Request -> Request -> Request
    Ord)

    data BatchWriteItem = BatchWriteItem {
          BatchWriteItem -> [(Text, [Request])]
    bwRequests :: [(T.Text,[Request])]
        -- ^ Put or Delete Requests for a specified table
        , BatchWriteItem -> ReturnConsumption
    bwRetCons :: ReturnConsumption
        , BatchWriteItem -> ReturnItemCollectionMetrics
    bwRetMet  :: ReturnItemCollectionMetrics
        } deriving (BatchWriteItem -> BatchWriteItem -> Bool
    (BatchWriteItem -> BatchWriteItem -> Bool)
    -> (BatchWriteItem -> BatchWriteItem -> Bool) -> Eq BatchWriteItem
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: BatchWriteItem -> BatchWriteItem -> Bool
    == :: BatchWriteItem -> BatchWriteItem -> Bool
    $c/= :: BatchWriteItem -> BatchWriteItem -> Bool
    /= :: BatchWriteItem -> BatchWriteItem -> Bool
    Eq,Int -> BatchWriteItem -> ShowS
    [BatchWriteItem] -> ShowS
    BatchWriteItem -> String
    (Int -> BatchWriteItem -> ShowS)
    -> (BatchWriteItem -> String)
    -> ([BatchWriteItem] -> ShowS)
    -> Show BatchWriteItem
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> BatchWriteItem -> ShowS
    showsPrec :: Int -> BatchWriteItem -> ShowS
    $cshow :: BatchWriteItem -> String
    show :: BatchWriteItem -> String
    $cshowList :: [BatchWriteItem] -> ShowS
    showList :: [BatchWriteItem] -> ShowS
    Show,ReadPrec [BatchWriteItem]
    ReadPrec BatchWriteItem
    Int -> ReadS BatchWriteItem
    ReadS [BatchWriteItem]
    (Int -> ReadS BatchWriteItem)
    -> ReadS [BatchWriteItem]
    -> ReadPrec BatchWriteItem
    -> ReadPrec [BatchWriteItem]
    -> Read BatchWriteItem
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS BatchWriteItem
    readsPrec :: Int -> ReadS BatchWriteItem
    $creadList :: ReadS [BatchWriteItem]
    readList :: ReadS [BatchWriteItem]
    $creadPrec :: ReadPrec BatchWriteItem
    readPrec :: ReadPrec BatchWriteItem
    $creadListPrec :: ReadPrec [BatchWriteItem]
    readListPrec :: ReadPrec [BatchWriteItem]
    Read,Eq BatchWriteItem
    Eq BatchWriteItem =>
    (BatchWriteItem -> BatchWriteItem -> Ordering)
    -> (BatchWriteItem -> BatchWriteItem -> Bool)
    -> (BatchWriteItem -> BatchWriteItem -> Bool)
    -> (BatchWriteItem -> BatchWriteItem -> Bool)
    -> (BatchWriteItem -> BatchWriteItem -> Bool)
    -> (BatchWriteItem -> BatchWriteItem -> BatchWriteItem)
    -> (BatchWriteItem -> BatchWriteItem -> BatchWriteItem)
    -> Ord BatchWriteItem
    BatchWriteItem -> BatchWriteItem -> Bool
    BatchWriteItem -> BatchWriteItem -> Ordering
    BatchWriteItem -> BatchWriteItem -> BatchWriteItem
    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 :: BatchWriteItem -> BatchWriteItem -> Ordering
    compare :: BatchWriteItem -> BatchWriteItem -> Ordering
    $c< :: BatchWriteItem -> BatchWriteItem -> Bool
    < :: BatchWriteItem -> BatchWriteItem -> Bool
    $c<= :: BatchWriteItem -> BatchWriteItem -> Bool
    <= :: BatchWriteItem -> BatchWriteItem -> Bool
    $c> :: BatchWriteItem -> BatchWriteItem -> Bool
    > :: BatchWriteItem -> BatchWriteItem -> Bool
    $c>= :: BatchWriteItem -> BatchWriteItem -> Bool
    >= :: BatchWriteItem -> BatchWriteItem -> Bool
    $cmax :: BatchWriteItem -> BatchWriteItem -> BatchWriteItem
    max :: BatchWriteItem -> BatchWriteItem -> BatchWriteItem
    $cmin :: BatchWriteItem -> BatchWriteItem -> BatchWriteItem
    min :: BatchWriteItem -> BatchWriteItem -> BatchWriteItem
    Ord)

    -------------------------------------------------------------------------------

    toBatchWrite :: [PutItem]
               -> [DeleteItem]
               -> BatchWriteItem
    toBatchWrite :: [PutItem] -> [DeleteItem] -> BatchWriteItem
    toBatchWrite [PutItem]
    ps [DeleteItem]
    ds =[(Text, [Request])]
    -> ReturnConsumption
    -> ReturnItemCollectionMetrics
    -> BatchWriteItem
    BatchWriteItem [(Text, [Request])]
    maps ReturnConsumption
    forall a. Default a => a
    def ReturnItemCollectionMetrics
    forall a. Default a => a
    def
          where
            maps :: [(T.Text,[Request])]
            maps :: [(Text, [Request])]
    maps = let pMap :: HashMap Text [Request]
    pMap = (HashMap Text [Request] -> PutItem -> HashMap Text [Request])
    -> HashMap Text [Request] -> [PutItem] -> HashMap Text [Request]
    forall b a. (b -> a -> b) -> b -> [a] -> b
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl (\HashMap Text [Request]
    acc PutItem
    p -> let key :: Text
    key = PutItem -> Text
    piTable PutItem
    p
                                                 in Text
    -> [Request] -> HashMap Text [Request] -> HashMap Text [Request]
    forall k v.
    (Eq k, Hashable k) =>
    k -> v -> HashMap k v -> HashMap k v
    HM.insert Text
    key (Item -> Request
    PutRequest (PutItem -> Item
    piItem PutItem
    p) Request -> [Request] -> [Request]
    forall a. a -> [a] -> [a]
    : ([Request] -> Text -> HashMap Text [Request] -> [Request]
    forall k v. (Eq k, Hashable k) => v -> k -> HashMap k v -> v
    HM.lookupDefault [] Text
    key HashMap Text [Request]
    acc)) HashMap Text [Request]
    acc) HashMap Text [Request]
    forall k v. HashMap k v
    HM.empty [PutItem]
    ps
                       totalMap :: HashMap Text [Request]
    totalMap = (HashMap Text [Request] -> DeleteItem -> HashMap Text [Request])
    -> HashMap Text [Request] -> [DeleteItem] -> HashMap Text [Request]
    forall b a. (b -> a -> b) -> b -> [a] -> b
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl (\HashMap Text [Request]
    acc DeleteItem
    d -> let key :: Text
    key = DeleteItem -> Text
    diTable DeleteItem
    d
                                                     in  Text
    -> [Request] -> HashMap Text [Request] -> HashMap Text [Request]
    forall k v.
    (Eq k, Hashable k) =>
    k -> v -> HashMap k v -> HashMap k v
    HM.insert Text
    key (PrimaryKey -> Request
    DeleteRequest (DeleteItem -> PrimaryKey
    diKey DeleteItem
    d) Request -> [Request] -> [Request]
    forall a. a -> [a] -> [a]
    : ([Request] -> Text -> HashMap Text [Request] -> [Request]
    forall k v. (Eq k, Hashable k) => v -> k -> HashMap k v -> v
    HM.lookupDefault [] Text
    key HashMap Text [Request]
    acc)) HashMap Text [Request]
    acc) HashMap Text [Request]
    pMap [DeleteItem]
    ds
                     in  HashMap Text [Request] -> [(Text, [Request])]
    forall k v. HashMap k v -> [(k, v)]
    HM.toList HashMap Text [Request]
    totalMap
    -- | Construct a BatchWriteItem
    batchWriteItem :: [(T.Text,[Request])]
                   -> BatchWriteItem
    batchWriteItem :: [(Text, [Request])] -> BatchWriteItem
    batchWriteItem [(Text, [Request])]
    reqs = [(Text, [Request])]
    -> ReturnConsumption
    -> ReturnItemCollectionMetrics
    -> BatchWriteItem
    BatchWriteItem [(Text, [Request])]
    reqs ReturnConsumption
    forall a. Default a => a
    def ReturnItemCollectionMetrics
    forall a. Default a => a
    def

    instance ToJSON Request where
       toJSON :: Request -> Value
    toJSON PutRequest{Item
    prItem :: Request -> Item
    prItem :: Item
    ..} =
           [Pair] -> Value
    object ([Pair] -> Value) -> [Pair] -> Value
    forall a b. (a -> b) -> a -> b
    $
             [ Key
    "PutRequest" Key -> Value -> Pair
    forall v. ToJSON v => Key -> v -> Pair
    forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
    .= ([Pair] -> Value
    object ([Pair] -> Value) -> [Pair] -> Value
    forall a b. (a -> b) -> a -> b
    $ [Key
    "Item" Key -> Item -> Pair
    forall v. ToJSON v => Key -> v -> Pair
    forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
    .= Item
    prItem])
             ]
       toJSON DeleteRequest{PrimaryKey
    drKey :: Request -> PrimaryKey
    drKey :: PrimaryKey
    ..} =
           [Pair] -> Value
    object ([Pair] -> Value) -> [Pair] -> Value
    forall a b. (a -> b) -> a -> b
    $
             [ Key
    "DeleteRequest" Key -> Value -> Pair
    forall v. ToJSON v => Key -> v -> Pair
    forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
    .=  ([Pair] -> Value
    object ([Pair] -> Value) -> [Pair] -> Value
    forall a b. (a -> b) -> a -> b
    $ [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
    drKey])
             ]

    instance ToJSON BatchWriteItem where
        toJSON :: BatchWriteItem -> Value
    toJSON BatchWriteItem{[(Text, [Request])]
    ReturnItemCollectionMetrics
    ReturnConsumption
    bwRequests :: BatchWriteItem -> [(Text, [Request])]
    bwRetCons :: BatchWriteItem -> ReturnConsumption
    bwRetMet :: BatchWriteItem -> ReturnItemCollectionMetrics
    bwRequests :: [(Text, [Request])]
    bwRetCons :: ReturnConsumption
    bwRetMet :: ReturnItemCollectionMetrics
    ..} =
            [Pair] -> Value
    object ([Pair] -> Value) -> [Pair] -> Value
    forall a b. (a -> b) -> a -> b
    $
              [ Key
    "RequestItems" Key -> HashMap Text [Request] -> Pair
    forall v. ToJSON v => Key -> v -> Pair
    forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
    .= [(Text, [Request])] -> HashMap Text [Request]
    forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
    HM.fromList [(Text, [Request])]
    bwRequests
              , 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
    bwRetCons
              , 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
    bwRetMet
              ]

    instance FromJSON Request where
        parseJSON :: Value -> Parser Request
    parseJSON = String -> (Object -> Parser Request) -> Value -> Parser Request
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
    withObject String
    "PutRequest or DeleteRequest" ((Object -> Parser Request) -> Value -> Parser Request)
    -> (Object -> Parser Request) -> Value -> Parser Request
    forall a b. (a -> b) -> a -> b
    $ \Object
    o ->

         [Parser Request] -> Parser Request
    forall (t :: * -> *) (f :: * -> *) a.
    (Foldable t, Alternative f) =>
    t (f a) -> f a
    asum [
               do
                 pr <- Object
    o Object -> Key -> Parser Object
    forall a. FromJSON a => Object -> Key -> Parser a
    .: Key
    "PutRequest"
                 i  <- pr .: "Item"
                 return $ PutRequest i ,
               do
                 dr <- Object
    o Object -> Key -> Parser Object
    forall a. FromJSON a => Object -> Key -> Parser a
    .: Key
    "DeleteRequest"
                 pk <- dr .: "Key"
                 return $ DeleteRequest pk
              ]

    data BatchWriteItemResponse = BatchWriteItemResponse {
          BatchWriteItemResponse -> [(Text, [Request])]
    bwUnprocessed    :: [(T.Text,[Request])]
        -- ^ Unprocessed Requests on failure
        , BatchWriteItemResponse -> Maybe ConsumedCapacity
    bwConsumed :: Maybe ConsumedCapacity
        -- ^ Amount of capacity consumed
        , BatchWriteItemResponse -> Maybe ItemCollectionMetrics
    bwColMet   :: Maybe ItemCollectionMetrics
        -- ^ Collection metrics for tables affected by BatchWriteItem.
        } deriving (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
    -> (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
    -> Eq BatchWriteItemResponse
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    == :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    $c/= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    /= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    Eq,Int -> BatchWriteItemResponse -> ShowS
    [BatchWriteItemResponse] -> ShowS
    BatchWriteItemResponse -> String
    (Int -> BatchWriteItemResponse -> ShowS)
    -> (BatchWriteItemResponse -> String)
    -> ([BatchWriteItemResponse] -> ShowS)
    -> Show BatchWriteItemResponse
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> BatchWriteItemResponse -> ShowS
    showsPrec :: Int -> BatchWriteItemResponse -> ShowS
    $cshow :: BatchWriteItemResponse -> String
    show :: BatchWriteItemResponse -> String
    $cshowList :: [BatchWriteItemResponse] -> ShowS
    showList :: [BatchWriteItemResponse] -> ShowS
    Show,ReadPrec [BatchWriteItemResponse]
    ReadPrec BatchWriteItemResponse
    Int -> ReadS BatchWriteItemResponse
    ReadS [BatchWriteItemResponse]
    (Int -> ReadS BatchWriteItemResponse)
    -> ReadS [BatchWriteItemResponse]
    -> ReadPrec BatchWriteItemResponse
    -> ReadPrec [BatchWriteItemResponse]
    -> Read BatchWriteItemResponse
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS BatchWriteItemResponse
    readsPrec :: Int -> ReadS BatchWriteItemResponse
    $creadList :: ReadS [BatchWriteItemResponse]
    readList :: ReadS [BatchWriteItemResponse]
    $creadPrec :: ReadPrec BatchWriteItemResponse
    readPrec :: ReadPrec BatchWriteItemResponse
    $creadListPrec :: ReadPrec [BatchWriteItemResponse]
    readListPrec :: ReadPrec [BatchWriteItemResponse]
    Read,Eq BatchWriteItemResponse
    Eq BatchWriteItemResponse =>
    (BatchWriteItemResponse -> BatchWriteItemResponse -> Ordering)
    -> (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
    -> (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
    -> (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
    -> (BatchWriteItemResponse -> BatchWriteItemResponse -> Bool)
    -> (BatchWriteItemResponse
        -> BatchWriteItemResponse -> BatchWriteItemResponse)
    -> (BatchWriteItemResponse
        -> BatchWriteItemResponse -> BatchWriteItemResponse)
    -> Ord BatchWriteItemResponse
    BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    BatchWriteItemResponse -> BatchWriteItemResponse -> Ordering
    BatchWriteItemResponse
    -> BatchWriteItemResponse -> BatchWriteItemResponse
    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 :: BatchWriteItemResponse -> BatchWriteItemResponse -> Ordering
    compare :: BatchWriteItemResponse -> BatchWriteItemResponse -> Ordering
    $c< :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    < :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    $c<= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    <= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    $c> :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    > :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    $c>= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    >= :: BatchWriteItemResponse -> BatchWriteItemResponse -> Bool
    $cmax :: BatchWriteItemResponse
    -> BatchWriteItemResponse -> BatchWriteItemResponse
    max :: BatchWriteItemResponse
    -> BatchWriteItemResponse -> BatchWriteItemResponse
    $cmin :: BatchWriteItemResponse
    -> BatchWriteItemResponse -> BatchWriteItemResponse
    min :: BatchWriteItemResponse
    -> BatchWriteItemResponse -> BatchWriteItemResponse
    Ord)

    instance Transaction BatchWriteItem BatchWriteItemResponse

    instance SignQuery BatchWriteItem where
        type ServiceConfiguration BatchWriteItem = DdbConfiguration
        signQuery :: forall queryType.
    BatchWriteItem
    -> ServiceConfiguration BatchWriteItem queryType
    -> SignatureData
    -> SignedQuery
    signQuery BatchWriteItem
    gi = ByteString
    -> BatchWriteItem
    -> DdbConfiguration queryType
    -> SignatureData
    -> SignedQuery
    forall a qt.
    ToJSON a =>
    ByteString
    -> a -> DdbConfiguration qt -> SignatureData -> SignedQuery
    ddbSignQuery ByteString
    "BatchWriteItem" BatchWriteItem
    gi

    instance FromJSON BatchWriteItemResponse where
        parseJSON :: Value -> Parser BatchWriteItemResponse
    parseJSON (Object Object
    v) = [(Text, [Request])]
    -> Maybe ConsumedCapacity
    -> Maybe ItemCollectionMetrics
    -> BatchWriteItemResponse
    BatchWriteItemResponse
            ([(Text, [Request])]
     -> Maybe ConsumedCapacity
     -> Maybe ItemCollectionMetrics
     -> BatchWriteItemResponse)
    -> (HashMap Text [Request] -> [(Text, [Request])])
    -> HashMap Text [Request]
    -> Maybe ConsumedCapacity
    -> Maybe ItemCollectionMetrics
    -> BatchWriteItemResponse
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> HashMap Text [Request] -> [(Text, [Request])]
    forall k v. HashMap k v -> [(k, v)]
    HM.toList (HashMap Text [Request]
     -> Maybe ConsumedCapacity
     -> Maybe ItemCollectionMetrics
     -> BatchWriteItemResponse)
    -> Parser (HashMap Text [Request])
    -> Parser
         (Maybe ConsumedCapacity
          -> Maybe ItemCollectionMetrics -> BatchWriteItemResponse)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Object
    v Object -> Key -> Parser (HashMap Text [Request])
    forall a. FromJSON a => Object -> Key -> Parser a
    .: Key
    "UnprocessedItems")
            Parser
      (Maybe ConsumedCapacity
       -> Maybe ItemCollectionMetrics -> BatchWriteItemResponse)
    -> Parser (Maybe ConsumedCapacity)
    -> Parser (Maybe ItemCollectionMetrics -> BatchWriteItemResponse)
    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 -> BatchWriteItemResponse)
    -> Parser (Maybe ItemCollectionMetrics)
    -> Parser BatchWriteItemResponse
    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 BatchWriteItemResponse
    forall a. String -> Parser a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "BatchWriteItemResponse must be an object."

    instance ResponseConsumer r BatchWriteItemResponse where
        type ResponseMetadata BatchWriteItemResponse = DdbResponse
        responseConsumer :: Request
    -> r
    -> IORef (ResponseMetadata BatchWriteItemResponse)
    -> HTTPResponseConsumer BatchWriteItemResponse
    responseConsumer Request
    _ r
    _ IORef (ResponseMetadata BatchWriteItemResponse)
    ref Response (ConduitM () ByteString (ResourceT IO) ())
    resp = IORef DdbResponse -> HTTPResponseConsumer BatchWriteItemResponse
    forall a. FromJSON a => IORef DdbResponse -> HTTPResponseConsumer a
    ddbResponseConsumer IORef (ResponseMetadata BatchWriteItemResponse)
    IORef DdbResponse
    ref Response (ConduitM () ByteString (ResourceT IO) ())
    resp

    instance AsMemoryResponse BatchWriteItemResponse where
        type MemoryResponse BatchWriteItemResponse = BatchWriteItemResponse
        loadToMemory :: BatchWriteItemResponse
    -> ResourceT IO (MemoryResponse BatchWriteItemResponse)
    loadToMemory = BatchWriteItemResponse
    -> ResourceT IO (MemoryResponse BatchWriteItemResponse)
    BatchWriteItemResponse -> ResourceT IO BatchWriteItemResponse
    forall a. a -> ResourceT IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return