Skip to content

dynamodb.Query can't get ConsumedCapacity #1108

@nekakoshi

Description

@nekakoshi

Hi contributor.

I want get ConsumedCapacity in dynamodb when execute dynamodb.Query.

I think unsupported return ConsumedCapacity in dynamodb.Query .

I want to be supported like to '%s.GetItem' and/or another solution. :)

cf: in my localstrage

@@ -182,6 +188,25 @@ class ProxyListenerDynamoDB(ProxyListener):
             if 'StreamSpecification' in data:
                 create_dynamodb_stream(data)
             return
+        elif action == '%s.Query' % ACTION_PREFIX:
+            print('%s.Query')
+            print(response.status_code)
+            if response.status_code == 200:
+                content = json.loads(to_str(response.content))
+                print(content)
+                # make sure we append 'ConsumedCapacity', which is properly
+                # returned by dynalite, but not by AWS's DynamoDBLocal
+                print('ConsumedCapacity')
+                print(content)
+                print(data.get('ReturnConsumedCapacity'))
+                if 'ConsumedCapacity' not in content and data.get('ReturnConsumedCapacity') in ('TOTAL', 'INDEXES'):
+                    print('hogehoge')
+                    content['ConsumedCapacity'] = {
+                        'CapacityUnits': 0.5,  # TODO hardcoded
+                        'TableName': data['TableName']
+                    }
+                    response._content = json.dumps(content)
+                    fix_headers_for_updated_response(response)
         else:
             # nothing to do
             return

Metadata

Metadata

Assignees

Labels

good first issueGood item to work on for newcomerstype: featureNew feature, or improvement to an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions