@@ -45,7 +45,7 @@ def __init__(
45
45
self ._encryption_config = encryption_config
46
46
47
47
def all (self ) -> Generator [EncryptedTable , None , None ]:
48
- """Creates an iterable of all EncryptedTable resources in the collection.
48
+ """Create an iterable of all EncryptedTable resources in the collection.
49
49
50
50
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/tables.html#DynamoDB.ServiceResource.all
51
51
@@ -56,7 +56,7 @@ def all(self) -> Generator[EncryptedTable, None, None]:
56
56
yield from self ._transform_table (self ._collection .all )
57
57
58
58
def filter (self , ** kwargs ) -> Generator [EncryptedTable , None , None ]:
59
- """Creates an iterable of all EncryptedTable resources in the collection filtered by kwargs passed to method.
59
+ """Create an iterable of all EncryptedTable resources in the collection filtered by kwargs passed to method.
60
60
61
61
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/tables.html#filter
62
62
@@ -67,7 +67,7 @@ def filter(self, **kwargs) -> Generator[EncryptedTable, None, None]:
67
67
yield from self ._transform_table (self ._collection .filter , ** kwargs )
68
68
69
69
def limit (self , ** kwargs ) -> Generator [EncryptedTable , None , None ]:
70
- """Creates an iterable of all EncryptedTable resources in the collection filtered by kwargs passed to method.
70
+ """Create an iterable of all EncryptedTable resources in the collection filtered by kwargs passed to method.
71
71
72
72
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/tables.html#limit
73
73
@@ -78,8 +78,9 @@ def limit(self, **kwargs) -> Generator[EncryptedTable, None, None]:
78
78
yield from self ._transform_table (self ._collection .limit , ** kwargs )
79
79
80
80
def page_size (self , ** kwargs ) -> Generator [EncryptedTable , None , None ]:
81
- """Creates an iterable of all EncryptedTable resources in the collection,
82
- but limits the number of items returned by each service call by the specified amount.
81
+ """Create an iterable of all EncryptedTable resources in the collection.
82
+
83
+ This limits the number of items returned by each service call by the specified amount.
83
84
84
85
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/tables.html#page_size
85
86
@@ -109,12 +110,38 @@ def _boto_client_attr_name(self) -> str:
109
110
110
111
111
112
class EncryptedResource (EncryptedBotoInterface ):
113
+ """Wrapper for a boto3 DynamoDB resource.
114
+
115
+ This class implements the complete boto3 DynamoDB resource API, allowing it to serve as a
116
+ drop-in replacement that transparently handles encryption and decryption of items.
117
+
118
+ The API matches the standard boto3 DynamoDB resource interface:
119
+ https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/index.html
120
+
121
+ This class will encrypt/decrypt items for the following operations:
122
+ * batch_get_item
123
+ * batch_write_item
124
+
125
+ Calling Table() will return an EncryptedTable object.
126
+
127
+ Any other operations on this class will defer to the underlying boto3 DynamoDB resource's implementation
128
+ and will not be encrypted/decrypted.
129
+
130
+ """
131
+
112
132
def __init__ (
113
133
self ,
114
134
* ,
115
135
resource : ServiceResource ,
116
136
encryption_config : DynamoDbTablesEncryptionConfig ,
117
137
):
138
+ """Create an EncryptedResource object.
139
+
140
+ Args:
141
+ resource (ServiceResource): Initialized boto3 DynamoDB resource
142
+ encryption_config (DynamoDbTablesEncryptionConfig): Initialized DynamoDbTablesEncryptionConfig
143
+
144
+ """
118
145
self ._resource = resource
119
146
self ._encryption_config = encryption_config
120
147
self ._transformer = DynamoDbEncryptionTransforms (config = encryption_config )
@@ -125,12 +152,12 @@ def __init__(
125
152
)
126
153
127
154
def Table (self , name ):
128
- """Creates an EncryptedTable resource.
155
+ """Create an EncryptedTable resource.
129
156
130
157
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/Table.html
131
158
132
159
Args:
133
- name (str): The EncryptedTable's name. This must be set.
160
+ name (str): The EncryptedTable's name identifier . This must be set.
134
161
135
162
Returns:
136
163
EncryptedTable: An EncryptedTable resource
@@ -139,20 +166,16 @@ def Table(self, name):
139
166
return EncryptedTable (table = self ._resource .Table (name ), encryption_config = self ._encryption_config )
140
167
141
168
def batch_get_item (self , ** kwargs ):
142
- """Gets multiple items from one or more tables. Decrypts any returned items.
169
+ """Get multiple items from one or more tables. Decrypts any returned items.
143
170
144
171
The parameters and return value match the boto3 DynamoDB batch_get_item API:
145
172
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/batch_get_item.html
146
173
147
174
Args:
148
- RequestItems (dict): A map of table names to lists of keys to retrieve
149
-
150
- These are only a list of required args; see boto3 docs for complete request structure.
175
+ **kwargs: Keyword arguments to pass to the operation. These match the boto3 batch_get_item API parameters.
151
176
152
177
Returns:
153
- dict: The response from DynamoDB containing the requested items.
154
-
155
- See boto3 docs for complete response structure.
178
+ dict: The response from DynamoDB. This matches the boto3 batch_get_item API response.
156
179
157
180
"""
158
181
return self ._resource_operation_logic (
@@ -170,20 +193,17 @@ def batch_get_item(self, **kwargs):
170
193
171
194
def batch_write_item (self , ** kwargs ):
172
195
"""Put or delete multiple items in one or more tables.
196
+
173
197
For put operations, encrypts items before writing.
174
198
175
199
The parameters and return value match the boto3 DynamoDB batch_write_item API:
176
200
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/service-resource/batch_write_item.html
177
201
178
202
Args:
179
- RequestItems (dict): A map of table names to lists of write operations
180
-
181
- These are only a list of required args; see boto3 docs for complete request structure.
203
+ **kwargs: Keyword arguments to pass to the operation. These match the boto3 batch_write_item API parameters.
182
204
183
205
Returns:
184
- dict: The response from DynamoDB.
185
-
186
- See boto3 docs for complete response structure.
206
+ dict: The response from DynamoDB. This matches the boto3 batch_write_item API response.
187
207
188
208
"""
189
209
return self ._resource_operation_logic (
0 commit comments