 (def db-item->clj-item (partial utils/keyword-map db-val->clj-val))
 (def clj-item->db-item (partial utils/name-map    clj-val->db-val))
 
+(defn- cc-units [^ConsumedCapacity cc] (some-> cc (.getCapacityUnits)))
+
 (defprotocol AsMap (as-map [x]))
 
 (defmacro ^:private am-item-result [result get-form]
   `(when-let [get-form# ~get-form]
      (with-meta (db-item->clj-item get-form#)
-       {:consumed-capacity (.getConsumedCapacity ~result)})))
+       {:consumed-capacity (cc-units (.getConsumedCapacity ~result))})))
 
 (defmacro ^:private am-query|scan-result [result & [meta]]
   `(let [result# ~result]
      (with-meta (mapv db-item->clj-item (.getItems result#))
        (merge {:count (.getCount result#)
-               :consumed-capacity (.getConsumedCapacity result#)
+               :consumed-capacity (cc-units (.getConsumedCapacity result#))
                :last-prim-kvs (as-map (.getLastEvaluatedKey result#))}
               ~meta))))
 

     :friends {:prim-kvs [{:catagory \"favorites\" :id [1 2 3]}
                          {:catagory \"recent\"    :id [7 8 9]}]}})"
  [creds requests]
  (as-map
   (.batchGetItem (db-client creds)
     (doto (BatchGetItemRequest.) ; {table-str KeysAndAttributes}
       (.setRequestItems (batch-request-items requests))))))

(defn- write-request [action item]
  (case action
    :put    (doto (WriteRequest.) (.setPutRequest    (doto (PutRequest.)    (.setItem item))))
    :delete (doto (WriteRequest.) (.setDeleteRequest (doto (DeleteRequest.) (.setKey  item))))))

(defn batch-write-item
  "Executes a batch of Puts and/or Deletes in a single request.

            com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient
            java.nio.ByteBuffer))

;; TODO setReturnConsumedCapacity enum for:
;; GetItem PutItem UpdateItem DeleteItem
;; Query Scan
;; BatchGetItem BatchWriteItem

;;;; Connections

(def ^:private db-client*
