o ckF[R&@sPddlmZGdddeZGdddeZGdddeZGdd d eZd S) )sixc@s&eZdZdZ  dddZddZdS) Batcha  Used to construct a BatchGet request. :ivar table: The Table object from which the item is retrieved. :ivar keys: A list of scalar or tuple values. Each element in the list represents one Item to retrieve. If the schema for the table has both a HashKey and a RangeKey, each element in the list should be a tuple consisting of (hash_key, range_key). If the schema for the table contains only a HashKey, each element in the list should be a scalar value of the appropriate type for the table schema. NOTE: The maximum number of items that can be retrieved for a single operation is 100. Also, the number of items retrieved is constrained by a 1 MB size limit. :ivar attributes_to_get: A list of attribute names. If supplied, only the specified attribute names will be returned. Otherwise, all attributes will be returned. :ivar consistent_read: Specify whether or not to use a consistent read. Defaults to False. NFcCs||_||_||_||_dSN)tablekeysattributes_to_getconsistent_readselfrrrrr 5/usr/lib/python3/dist-packages/boto/dynamodb/batch.py__init__3s zBatch.__init__cCsi}g}|jD] }t|tr|\}}n|}d}|jj|jj||}||q||d<|jr4|j|d<|j r=d|d<|Sd|d<|S)O Convert the Batch object into the format required for Layer1. NKeysAttributesToGetTConsistentReadF) r isinstancetuplerlayer2build_key_from_valuesschemaappendrr)r batch_dictkey_listkeyhash_key range_keykr r r to_dict:s&     z Batch.to_dictNF__name__ __module__ __qualname____doc__r rr r r r rs  rc@s"eZdZdZdddZddZdS) BatchWritea Used to construct a BatchWrite request. Each BatchWrite object represents a collection of PutItem and DeleteItem requests for a single Table. :ivar table: The Table object from which the item is retrieved. :ivar puts: A list of :class:`boto.dynamodb.item.Item` objects that you want to write to DynamoDB. :ivar deletes: A list of scalar or tuple values. Each element in the list represents one Item to delete. If the schema for the table has both a HashKey and a RangeKey, each element in the list should be a tuple consisting of (hash_key, range_key). If the schema for the table contains only a HashKey, each element in the list should be a scalar value of the appropriate type for the table schema. NcCs||_|pg|_|p g|_dSr)rputsdeletesr rr&r'r r r r gs zBatchWrite.__init__cCsg}|jD]}d|jj|i}d|i}||q|jD]&}t|tr)|\}}n|}d}|jj|jj ||}d|i}|d|iq|jj |fS)rItem PutRequestNKey DeleteRequest) r&rr dynamize_itemrr'rrrrname)r op_listitemdrrrrr r r rls       zBatchWrite.to_dictNNr r r r r r%Ss  r%c@s>eZdZdZddZ  dddZdd Zd d Zd d ZdS) BatchListzs A subclass of a list object that contains a collection of :class:`boto.dynamodb.batch.Batch` objects. cCst|d|_||_dSr)listr unprocessedrr rr r r r s  zBatchList.__init__NFcCs|t||||dS)aO Add a Batch to this BatchList. :type table: :class:`boto.dynamodb.table.Table` :param table: The Table object in which the items are contained. :type keys: list :param keys: A list of scalar or tuple values. Each element in the list represents one Item to retrieve. If the schema for the table has both a HashKey and a RangeKey, each element in the list should be a tuple consisting of (hash_key, range_key). If the schema for the table contains only a HashKey, each element in the list should be a scalar value of the appropriate type for the table schema. NOTE: The maximum number of items that can be retrieved for a single operation is 100. Also, the number of items retrieved is constrained by a 1 MB size limit. :type attributes_to_get: list :param attributes_to_get: A list of attribute names. If supplied, only the specified attribute names will be returned. Otherwise, all attributes will be returned. N)rrr r r r add_batchszBatchList.add_batchc Cs|dd=|js dSt|jD]<\}}|d}|j|}g}|D]}|d}d}d|vr2|d}|||fq"d} d|vrD|d} |j||| dq|S)a Resubmit the batch to get the next result set. The request object is rebuild from scratch meaning that all batch added between ``submit`` and ``resubmit`` will be lost. Note: This method is experimental and subject to changes in future releases NrHashKeyElementRangeKeyElementr)r)r5r iteritemsr get_tablerr7submit) r table_name table_req table_keysrrrhrrr r r resubmits$  zBatchList.resubmitcCs"|j|}d|vr|d|_|S)NUnprocessedKeys)rbatch_get_itemr5)r resr r r r<s  zBatchList.submitcCs.i}|D]}|}|dr|||jj<q|S)zM Convert a BatchList object into format required for Layer1. r)rrr.)r r1batchbr r r rs zBatchList.to_dictr) r!r"r#r$r r7rBr<rr r r r r3s ! r3c@s2eZdZdZddZd ddZddZd d ZdS) BatchWriteListzx A subclass of a list object that contains a collection of :class:`boto.dynamodb.batch.BatchWrite` objects. cCst|||_dSr)r4r rr6r r r r s  zBatchWriteList.__init__NcCs|t|||dS)aW Add a BatchWrite to this BatchWriteList. :type table: :class:`boto.dynamodb.table.Table` :param table: The Table object in which the items are contained. :type puts: list of :class:`boto.dynamodb.item.Item` objects :param puts: A list of items that you want to write to DynamoDB. :type deletes: A list :param deletes: A list of scalar or tuple values. Each element in the list represents one Item to delete. If the schema for the table has both a HashKey and a RangeKey, each element in the list should be a tuple consisting of (hash_key, range_key). If the schema for the table contains only a HashKey, each element in the list should be a scalar value of the appropriate type for the table schema. N)rr%r(r r r r7szBatchWriteList.add_batchcCs |j|Sr)rbatch_write_item)r r r r r<s zBatchWriteList.submitcCs&i}|D] }|\}}|||<q|S)zR Convert a BatchWriteList object into format required for Layer1. )r)r r1rFr=rr r r rs   zBatchWriteList.to_dictr2)r!r"r#r$r r7r<rr r r r rHs   rHN) boto.compatrobjectrr%r4r3rHr r r r s 9/X