Skip to content

Commit a9da8b2

Browse files
author
Lucas McDonald
committed
sync
1 parent a02c71c commit a9da8b2

File tree

6 files changed

+294
-146
lines changed

6 files changed

+294
-146
lines changed

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/internal/client_to_resource.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
13
from aws_cryptography_internal_dynamodb.smithygenerated.com_amazonaws_dynamodb.boto3_conversions import (
24
InternalBoto3DynamoDBFormatConverter,
35
)
@@ -7,6 +9,12 @@
79
class ClientShapeToResourceShapeConverter:
810

911
def __init__(self, delete_table_name=True):
12+
# Some callers expect the TableName kwarg to be removed from the outputs of this class.
13+
# (EncryptedResource, EncryptedTable.)
14+
# These callers' boto3 shapes do not include TableName.
15+
# Other callers expect the TableName kwarg to be included in the outputs of this class.
16+
# (EncryptedClient, EncryptedPaginator.)
17+
# These callers' boto3 shapes include TableName.
1018
self.delete_table_name = delete_table_name
1119
self.boto3_converter = InternalBoto3DynamoDBFormatConverter(
1220
item_handler=TypeDeserializer().deserialize, condition_handler=self.condition_handler
@@ -16,14 +24,13 @@ def condition_handler(self, expression_key, request):
1624
"""Returns the input condition/names/values as-is."""
1725
# Conditions do not need to be converted from strings to boto3 Attrs.
1826
# Resources accept either strings or Attrs.
27+
# Return the provided condition string.
1928
condition = request[expression_key]
2029

21-
# This conversion in client_to_resource does not update neither
22-
# ExpressionAttributeNames nor ExpressionAttributeValues.
23-
# However, resource_to_client condition_handler may add new
24-
# ExpressionAttributeNames and ExpressionAttributeValues.
25-
# Smithy-generated code expects condition_handlers to return
26-
# ExpressionAttributeNames and ExpressionAttributeValues.
30+
# This conversion in client_to_resource does not update ExpressionAttributeNames or ExpressionAttributeValues.
31+
# However, resource_to_client condition_handler may add new ExpressionAttributeNames and ExpressionAttributeValues.
32+
# Smithy-generated code expects condition_handlers to return ExpressionAttributeNames and ExpressionAttributeValues,
33+
# expecting empty dicts if there are none.
2734
try:
2835
names = request["ExpressionAttributeNames"]
2936
except KeyError:
@@ -37,7 +44,7 @@ def condition_handler(self, expression_key, request):
3744

3845
def put_item_request(self, put_item_request):
3946
out = self.boto3_converter.PutItemInput(put_item_request)
40-
# put_item requests on a boto3.resource.Table do not have a table name.
47+
# put_item requests on resources do not have a table name.
4148
if self.delete_table_name:
4249
del out["TableName"]
4350
return out
@@ -47,7 +54,7 @@ def put_item_response(self, put_item_response):
4754

4855
def get_item_request(self, get_item_request):
4956
out = self.boto3_converter.GetItemInput(get_item_request)
50-
# get_item requests on a boto3.resource.Table do not have a table name.
57+
# get_item requests on resources do not have a table name.
5158
if self.delete_table_name:
5259
del out["TableName"]
5360
return out
@@ -57,7 +64,7 @@ def get_item_response(self, get_item_response):
5764

5865
def query_request(self, query_request):
5966
out = self.boto3_converter.QueryInput(query_request)
60-
# query requests on a boto3.resource.Table do not have a table name.
67+
# query requests on resources do not have a table name.
6168
if self.delete_table_name:
6269
del out["TableName"]
6370
return out
@@ -67,27 +74,33 @@ def query_response(self, query_response):
6774

6875
def scan_request(self, scan_request):
6976
out = self.boto3_converter.ScanInput(scan_request)
70-
# scan requests on a boto3.resource.Table do not have a table name.
77+
# scan requests on resources do not have a table name.
7178
if self.delete_table_name:
7279
del out["TableName"]
7380
return out
7481

82+
def scan_response(self, scan_response):
83+
return self.boto3_converter.ScanOutput(scan_response)
84+
7585
def delete_item_request(self, delete_item_request):
7686
out = self.boto3_converter.DeleteItemInput(delete_item_request)
77-
# delete_item requests on a boto3.resource.Table do not have a table name.
87+
# delete_item requests on resources do not have a table name.
7888
if self.delete_table_name:
7989
del out["TableName"]
8090
return out
91+
92+
def delete_item_response(self, delete_item_response):
93+
return self.boto3_converter.DeleteItemOutput(delete_item_response)
8194

8295
def update_item_request(self, update_item_request):
8396
out = self.boto3_converter.UpdateItemInput(update_item_request)
84-
# update_item requests on a boto3.resource.Table do not have a table name.
97+
# update_item requests on resources do not have a table name.
8598
if self.delete_table_name:
8699
del out["TableName"]
87100
return out
88-
89-
def scan_response(self, scan_response):
90-
return self.boto3_converter.ScanOutput(scan_response)
101+
102+
def update_item_response(self, update_item_response):
103+
return self.boto3_converter.UpdateItemOutput(update_item_response)
91104

92105
def transact_get_items_request(self, transact_get_items_request):
93106
return self.boto3_converter.TransactGetItemsInput(transact_get_items_request)
@@ -113,18 +126,12 @@ def batch_write_item_request(self, batch_write_item_request):
113126
def batch_write_item_response(self, batch_write_item_response):
114127
return self.boto3_converter.BatchWriteItemOutput(batch_write_item_response)
115128

116-
def update_item_response(self, update_item_response):
117-
return self.boto3_converter.UpdateItemOutput(update_item_response)
118-
119129
def batch_execute_statement_request(self, batch_execute_statement_request):
120130
return self.boto3_converter.BatchExecuteStatementInput(batch_execute_statement_request)
121131

122132
def batch_execute_statement_response(self, batch_execute_statement_response):
123133
return self.boto3_converter.BatchExecuteStatementOutput(batch_execute_statement_response)
124134

125-
def delete_item_response(self, delete_item_response):
126-
return self.boto3_converter.DeleteItemOutput(delete_item_response)
127-
128135
def execute_statement_request(self, execute_statement_request):
129136
return self.boto3_converter.ExecuteStatementInput(execute_statement_request)
130137

0 commit comments

Comments
 (0)