o ckF[]@slddlZddlmZddlZddlmZddlmZddlm Z ddl m Z ddl mZGdd d eZdS) N)crc32)AWSAuthConnection)DynamoDBResponseError)Provider) exceptions)jsoncs eZdZdZdZ dZ dZ dZ dZ dZ dZ e Z d Z d5fd d ZddZddZd6ddZddZddZd7ddZddZddZd d!Zd"d#Z d8d%d&Zd9d'd(Zd9d)d*Z d:d+d,Z d:d-d.Z d:d/d0Z $ $d;d1d2Z $d|||d}|r ||d<|r||d<t|}|jd||dS)af Edits an existing item's attributes. You can perform a conditional update (insert a new attribute name-value pair if it doesn't exist, or replace an existing name-value pair if it has certain expected attribute values). :type table_name: str :param table_name: The name of the table. :type key: dict :param key: A Python version of the Key data structure defined by DynamoDB which identifies the item to be updated. :type attribute_updates: dict :param attribute_updates: A Python version of the AttributeUpdates data structure defined by DynamoDB. :type expected: dict :param expected: A Python version of the Expected data structure defined by DynamoDB. :type return_values: str :param return_values: Controls the return of attribute name-value pairs before then were changed. Possible values are: None or 'ALL_OLD'. If 'ALL_OLD' is specified and the item is overwritten, the content of the old item is returned. )rrAttributeUpdatesrr UpdateItemr@ry) r"rrattribute_updatesrrrArmr}r-r-r. update_items zLayer1.update_itemcCr)aK Delete an item and all of it's attributes by primary key. You can perform a conditional delete by specifying an expected rule. :type table_name: str :param table_name: The name of the table containing the item. :type key: dict :param key: A Python version of the Key data structure defined by DynamoDB. :type expected: dict :param expected: A Python version of the Expected data structure defined by DynamoDB. :type return_values: str :param return_values: Controls the return of attribute name-value pairs before then were changed. Possible values are: None or 'ALL_OLD'. If 'ALL_OLD' is specified and the item is overwritten, the content of the old item is returned. rrr DeleteItemr@ry)r"rrrrrArmr}r-r-r. delete_items zLayer1.delete_itemc Cs||d} |r || d<|r|| d<|r|| d<| rd| d<|r#d| d<|r*d| d<nd | d<|r4|| d <t| } |jd | | d S) a Perform a query of DynamoDB. This version is currently punting and expecting you to provide a full and correct JSON body which is passed as is to DynamoDB. :type table_name: str :param table_name: The name of the table to query. :type hash_key_value: dict :param key: A DynamoDB-style HashKeyValue. :type range_key_conditions: dict :param range_key_conditions: A Python version of the RangeKeyConditions data structure. :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. :type limit: int :param limit: The maximum number of items to return. :type count: bool :param count: If True, Amazon DynamoDB returns a total number of items for the Query operation, even if the operation has no matching items for the assigned filter. :type consistent_read: bool :param consistent_read: If True, a consistent read request is issued. Otherwise, an eventually consistent request is issued. :type scan_index_forward: bool :param scan_index_forward: Specified forward or backward traversal of the index. Default is forward (True). :type exclusive_start_key: list or tuple :param exclusive_start_key: Primary key of the item from which to continue an earlier query. This would be provided as the LastEvaluatedKey in that query. )r HashKeyValueRangeKeyConditionrrvTCountrScanIndexForwardFExclusiveStartKeyQueryr@ry) r"rhash_key_valuerange_key_conditionsrr{rscan_index_forwardexclusive_start_keyrAcountrmr}r-r-r.querys,.  z Layer1.queryc Cs^d|i}|r ||d<|r||d<|r||d<|rd|d<|r"||d<t|} |jd| |d S) a Perform a scan of DynamoDB. This version is currently punting and expecting you to provide a full and correct JSON body which is passed as is to DynamoDB. :type table_name: str :param table_name: The name of the table to scan. :type scan_filter: dict :param scan_filter: A Python version of the ScanFilter data structure. :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. :type limit: int :param limit: The maximum number of items to evaluate. :type count: bool :param count: If True, Amazon DynamoDB returns a total number of items for the Scan operation, even if the operation has no matching items for the assigned filter. :type exclusive_start_key: list or tuple :param exclusive_start_key: Primary key of the item from which to continue an earlier query. This would be provided as the LastEvaluatedKey in that query. r ScanFilterrrvTrrScanr@ry) r"r scan_filterrr{rrArrmr}r-r-r.scans! z Layer1.scan) NNTNNNrNNTTN)r7N)NN)NFNr/)NNN)NNNFTNNF)NNNNNF)"__name__ __module__ __qualname____doc__rrBrCr_rdrfrhrrjrIrr5r6r[rJr`r~rrrrrrrrrrrr __classcell__r-r-r+r.r"sr  +    &  ( + $ Dr)rGbinasciirrboto.connectionrboto.exceptionr boto.providerr boto.dynamodbrra boto.compatrrr-r-r-r.s