1
+ # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
1
3
from aws_cryptography_internal_dynamodb .smithygenerated .com_amazonaws_dynamodb .boto3_conversions import (
2
4
InternalBoto3DynamoDBFormatConverter ,
3
5
)
7
9
class ClientShapeToResourceShapeConverter :
8
10
9
11
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.
10
18
self .delete_table_name = delete_table_name
11
19
self .boto3_converter = InternalBoto3DynamoDBFormatConverter (
12
20
item_handler = TypeDeserializer ().deserialize , condition_handler = self .condition_handler
@@ -16,14 +24,13 @@ def condition_handler(self, expression_key, request):
16
24
"""Returns the input condition/names/values as-is."""
17
25
# Conditions do not need to be converted from strings to boto3 Attrs.
18
26
# Resources accept either strings or Attrs.
27
+ # Return the provided condition string.
19
28
condition = request [expression_key ]
20
29
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.
27
34
try :
28
35
names = request ["ExpressionAttributeNames" ]
29
36
except KeyError :
@@ -37,7 +44,7 @@ def condition_handler(self, expression_key, request):
37
44
38
45
def put_item_request (self , put_item_request ):
39
46
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.
41
48
if self .delete_table_name :
42
49
del out ["TableName" ]
43
50
return out
@@ -47,7 +54,7 @@ def put_item_response(self, put_item_response):
47
54
48
55
def get_item_request (self , get_item_request ):
49
56
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.
51
58
if self .delete_table_name :
52
59
del out ["TableName" ]
53
60
return out
@@ -57,7 +64,7 @@ def get_item_response(self, get_item_response):
57
64
58
65
def query_request (self , query_request ):
59
66
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.
61
68
if self .delete_table_name :
62
69
del out ["TableName" ]
63
70
return out
@@ -67,27 +74,33 @@ def query_response(self, query_response):
67
74
68
75
def scan_request (self , scan_request ):
69
76
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.
71
78
if self .delete_table_name :
72
79
del out ["TableName" ]
73
80
return out
74
81
82
+ def scan_response (self , scan_response ):
83
+ return self .boto3_converter .ScanOutput (scan_response )
84
+
75
85
def delete_item_request (self , delete_item_request ):
76
86
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.
78
88
if self .delete_table_name :
79
89
del out ["TableName" ]
80
90
return out
91
+
92
+ def delete_item_response (self , delete_item_response ):
93
+ return self .boto3_converter .DeleteItemOutput (delete_item_response )
81
94
82
95
def update_item_request (self , update_item_request ):
83
96
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.
85
98
if self .delete_table_name :
86
99
del out ["TableName" ]
87
100
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 )
91
104
92
105
def transact_get_items_request (self , transact_get_items_request ):
93
106
return self .boto3_converter .TransactGetItemsInput (transact_get_items_request )
@@ -113,18 +126,12 @@ def batch_write_item_request(self, batch_write_item_request):
113
126
def batch_write_item_response (self , batch_write_item_response ):
114
127
return self .boto3_converter .BatchWriteItemOutput (batch_write_item_response )
115
128
116
- def update_item_response (self , update_item_response ):
117
- return self .boto3_converter .UpdateItemOutput (update_item_response )
118
-
119
129
def batch_execute_statement_request (self , batch_execute_statement_request ):
120
130
return self .boto3_converter .BatchExecuteStatementInput (batch_execute_statement_request )
121
131
122
132
def batch_execute_statement_response (self , batch_execute_statement_response ):
123
133
return self .boto3_converter .BatchExecuteStatementOutput (batch_execute_statement_response )
124
134
125
- def delete_item_response (self , delete_item_response ):
126
- return self .boto3_converter .DeleteItemOutput (delete_item_response )
127
-
128
135
def execute_statement_request (self , execute_statement_request ):
129
136
return self .boto3_converter .ExecuteStatementInput (execute_statement_request )
130
137
0 commit comments