FRTc@sddlZddlmZddlZddlmZddlmZddlm Z ddl m Z ddl mZdefd YZdS( iN(tcrc32(tAWSAuthConnection(tDynamoDBResponseError(tProvider(t exceptions(tjsontLayer1c BsseZdZdZdZdZdZdZdZdZ e Z dZ ddedddd ddeedd Zd Zd Zd ddZdZdZdddZdZdZdZdZdeddZddZddZddddZddddZddddZ dddeeddedZ!dddddedZ"RS(se This is the lowest-level interface to DynamoDB. Methods at this layer map directly to API requests and parameters to the methods are either simple, scalar values or they are the Python equivalent of the JSON input as defined in the DynamoDB Developer's Guide. All responses are direct decoding of the JSON response bodies to Python data structures via the json or simplejson modules. :ivar throughput_exceeded_events: An integer variable that keeps a running total of the number of ThroughputExceeded responses this connection has received from Amazon DynamoDB. s us-east-1tDynamoDBt20111205t&ProvisionedThroughputExceededExceptions.com.amazon.coral.service#ExpiredTokenExceptiontConditionalCheckFailedExceptiontValidationExceptioni ic Cs| sWtjjdd|j} x3tjjD]}|j| kr1|} Pq1q1Wn| |_tt |j |jj ||||||d|d|d| d| d|_ tjj dd| |_dS( NRtregiontdebugtsecurity_tokentvalidate_certst profile_nameitvalidate_checksums(tbototconfigtgettDefaultRegionNametdynamodbtregionstnameR tsuperRt__init__tendpointtthroughput_exceeded_eventstgetboolt_validate_checksums(tselftaws_access_key_idtaws_secret_access_keyt is_securetporttproxyt proxy_portR RR RRRt region_nametreg((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyRJs$      cCs)t|j|_|jj|jdS(N(Rt_provider_typetprovidert _auth_handlertupdate_provider(R((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyt_get_session_tokenbscCsdgS(Nshmac-v4((R((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyt_required_auth_capabilityfstc Cs-id|j|j|fd6|jjd6dd6tt|d6}|jdddi||d}tj}|j |d dd |j d |j }tj|d }|j d } t jjd| t jjd|d| t||jjd} t jj| tj| d|S(sW :raises: ``DynamoDBExpiredTokenError`` if the security token expires. s%s_%s.%ss X-Amz-TargettHostsapplication/x-amz-json-1.0s Content-TypesContent-LengthtPOSTt/tsendertoverride_num_retriest retry_handlerisx-amzn-RequestIds RequestId: %ss%s: id=%s time=%smssutf-8t object_hookN(t ServiceNametVersionR Rtstrtlentbuild_base_http_requesttNonettimet_mexet NumberRetriest_retry_handlert getheaderRtlogR tperflogtinttreadtdecodeRtloads( RtactiontbodyR5theaderst http_requesttstarttresponsetelapsedt request_idt response_body((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyt make_requestis&      c CsTd}|jdkr|jjd}tjj|tj|}|j |j dkr|j d7_ d|j |f}|j |}|d7}|||f}||j krtj|j|j|qq|j|j dkr d}|j|||jddf}q|j|j dkrVtj|j|j|q|j|j dkrtj|j|j|q|j|j|j|n|jd}|jrP|dk rPtjjd |jjdt|jd @} t|}| |krPd | |f}||d|j |f}qPn|S( Nisutf-8t__typeis%s, retry attempt %ssRenewing Session Tokenis x-amz-crc32s&Validating crc32 checksum for body: %sIsAThe calculated checksum %s did not match the expected checksum %s(R;tstatusRDRERRAR RRFt ThruputErrorRRt_exponential_timeR>tdynamodb_exceptionstDynamoDBThroughputExceededErrortreasontSessionExpiredErrorR,t num_retriestConditionalCheckFailedErrort#DynamoDBConditionalCheckFailedErrortValidationErrortDynamoDBValidationErrort ResponseErrorR@RRRC( RRLtit next_sleepRRROtdatatmsgtexpected_crc32t actual_crc32((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyR?sJ       "cCsB|dkrd}n)tdd|tjjddd}|S(Nig?itBototmax_retry_delayi<(tminRRR(RR_R`((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyRTs   cCsKi}|r||dR;RRR,R-RPR?RTRoRsRzR|R~RRRRRRRRR(((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyR"sR      +    %   & ) " A(R<tbinasciiRRtboto.connectionRtboto.exceptionRt boto.providerRt boto.dynamodbRRUt boto.compatRR(((sA/opt/freeware/lib/python2.7/site-packages/boto/dynamodb/layer1.pyts