@@ -52,6 +52,7 @@ def encrypt_python_item(
52
52
then return the encrypted Python dictionary.
53
53
54
54
See the boto3 documentation for details on Python/DynamoDB type transfomations:
55
+
55
56
https://boto3.amazonaws.com/v1/documentation/api/latest/_modules/boto3/dynamodb/types.html
56
57
57
58
boto3 DynamoDB Tables and Resources expect items formatted as native Python dictionaries.
@@ -94,29 +95,32 @@ def encrypt_dynamodb_item(
94
95
Encrypt DynamoDB-formatted JSON.
95
96
96
97
boto3 DynamoDB clients expect items formatted as DynamoDB JSON:
98
+
97
99
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html
100
+
98
101
Use this method to encrypt an item if you intend to pass the encrypted item
99
- to a boto3 DynamoDB client to store it.
102
+ to a boto3 DynamoDB client to store it.
100
103
(Alternatively, you can use this library's EncryptedClient interface
101
- to transparently encrypt items without an intermediary ItemEncryptor.)
104
+ to transparently encrypt items without an intermediary ItemEncryptor.)
102
105
103
106
Args:
104
107
plaintext_dynamodb_item (dict[str, dict[str, Any]]): The item to encrypt formatted as DynamoDB JSON.
105
108
106
109
Returns:
107
110
EncryptItemOutput: Structure containing the following fields:
108
- - `encrypted_item` (dict[str, Any]): A dictionary containing the encrypted DynamoDB item
109
- formatted as DynamoDB JSON.
110
- - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header (`aws_dbe_head` value).
111
+
112
+ - encrypted_item (dict[str, Any]): A dictionary containing the encrypted DynamoDB item
113
+ formatted as DynamoDB JSON.
114
+ - parsed_header (Optional[ParsedHeader]): The encrypted DynamoDB item's header (`aws_dbe_head` value).
111
115
112
116
Example:
113
- >>> plaintext_item = {
114
- ... 'some': {'S': 'data'},
115
- ... 'more': {'N': '5'}
116
- ... }
117
- >>> encrypt_output = item_encryptor.encrypt_dynamodb_item(plaintext_item)
118
- >>> encrypted_item = encrypt_output.encrypted_item
119
- >>> header = encrypt_output.parsed_header
117
+ >>> plaintext_item = {
118
+ ... 'some': {'S': 'data'},
119
+ ... 'more': {'N': '5'}
120
+ ... }
121
+ >>> encrypt_output = item_encryptor.encrypt_dynamodb_item(plaintext_item)
122
+ >>> encrypted_item = encrypt_output.encrypted_item
123
+ >>> header = encrypt_output.parsed_header
120
124
121
125
"""
122
126
return self .encrypt_item (EncryptItemInput (plaintext_item = plaintext_dynamodb_item ))
@@ -129,30 +133,33 @@ def encrypt_item(
129
133
Encrypt a DynamoDB item.
130
134
131
135
The input item should contain a dictionary formatted as DynamoDB JSON:
136
+
132
137
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html
133
138
134
139
Args:
135
140
encrypt_item_input (EncryptItemInput): Structure containing the following field:
136
- - `plaintext_item` (dict[str, Any]): The item to encrypt formatted as DynamoDB JSON.
141
+
142
+ - plaintext_item (dict[str, Any]): The item to encrypt formatted as DynamoDB JSON.
137
143
138
144
Returns:
139
145
EncryptItemOutput: Structure containing the following fields:
140
- - `encrypted_item` (dict[str, Any]): The encrypted DynamoDB item formatted as DynamoDB JSON.
141
- - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header
142
- (`aws_dbe_head` value).
146
+
147
+ - encrypted_item (dict[str, Any]): The encrypted DynamoDB item formatted as DynamoDB JSON.
148
+ - parsed_header (Optional[ParsedHeader]): The encrypted DynamoDB item's header
149
+ (`aws_dbe_head` value).
143
150
144
151
Example:
145
- >>> plaintext_item = {
146
- ... 'some': {'S': 'data'},
147
- ... 'more': {'N': '5'}
148
- ... }
149
- >>> encrypt_output = item_encryptor.encrypt_item(
150
- ... EncryptItemInput(
151
- ... plaintext_ddb_item = plaintext_item
152
- ... )
153
- ... )
154
- >>> encrypted_item = encrypt_output.encrypted_item
155
- >>> header = encrypt_output.parsed_header
152
+ >>> plaintext_item = {
153
+ ... 'some': {'S': 'data'},
154
+ ... 'more': {'N': '5'}
155
+ ... }
156
+ >>> encrypt_output = item_encryptor.encrypt_item(
157
+ ... EncryptItemInput(
158
+ ... plaintext_ddb_item = plaintext_item
159
+ ... )
160
+ ... )
161
+ >>> encrypted_item = encrypt_output.encrypted_item
162
+ >>> header = encrypt_output.parsed_header
156
163
157
164
"""
158
165
return self ._internal_client .encrypt_item (encrypt_item_input )
@@ -165,37 +172,39 @@ def decrypt_python_item(
165
172
Decrypt a Python dictionary.
166
173
167
174
This method will transform the Python dictionary into DynamoDB JSON,
168
- decrypt the DynamoDB JSON,
169
- transform the plaintext DynamoDB JSON into a plaintext Python dictionary,
170
- then return the plaintext Python dictionary.
175
+ decrypt the DynamoDB JSON,
176
+ transform the plaintext DynamoDB JSON into a plaintext Python dictionary,
177
+ then return the plaintext Python dictionary.
171
178
172
179
See the boto3 documentation for details on Python/DynamoDB type transfomations:
180
+
173
181
https://boto3.amazonaws.com/v1/documentation/api/latest/_modules/boto3/dynamodb/types.html
174
182
175
183
boto3 DynamoDB Tables and Resources return items formatted as native Python dictionaries.
176
184
Use this method to decrypt an item if you retrieve the encrypted item
177
- from a boto3 DynamoDB Table or Resource interface.
185
+ from a boto3 DynamoDB Table or Resource interface.
178
186
(Alternatively, you can use this library's EncryptedTable or EncryptedResource interfaces
179
- to transparently decrypt items without an intermediary ItemEncryptor.)
187
+ to transparently decrypt items without an intermediary ItemEncryptor.)
180
188
181
189
Args:
182
190
encrypted_dict_item (dict[str, Any]): A standard Python dictionary with encrypted values.
183
191
184
192
Returns:
185
193
DecryptItemOutput: Structure containing the following fields:
186
- - `plaintext_item` (dict[str, Any]): The decrypted Python dictionary.
187
- **Note:** The item was decrypted as DynamoDB JSON, then transformed to a Python dictionary.
188
- - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header
194
+
195
+ - plaintext_item (dict[str, Any]): The decrypted Python dictionary.
196
+ **Note:** The item was decrypted as DynamoDB JSON, then transformed to a Python dictionary.
197
+ - parsed_header (Optional[ParsedHeader]): The encrypted DynamoDB item's header
189
198
(parsed `aws_dbe_head` value).
190
199
191
200
Example:
192
- >>> encrypted_item = {
193
- ... 'some': b'ENCRYPTED_DATA',
194
- ... 'more': b'ENCRYPTED_DATA',
195
- ... }
196
- >>> decrypt_output = item_encryptor.decrypt_python_item(encrypted_item)
197
- >>> plaintext_item = decrypt_output.plaintext_item
198
- >>> header = decrypt_output.parsed_header
201
+ >>> encrypted_item = {
202
+ ... 'some': b'ENCRYPTED_DATA',
203
+ ... 'more': b'ENCRYPTED_DATA',
204
+ ... }
205
+ >>> decrypt_output = item_encryptor.decrypt_python_item(encrypted_item)
206
+ >>> plaintext_item = decrypt_output.plaintext_item
207
+ >>> header = decrypt_output.parsed_header
199
208
200
209
"""
201
210
encrypted_ddb_item = dict_to_ddb (encrypted_dict_item )
@@ -211,28 +220,31 @@ def decrypt_dynamodb_item(
211
220
Decrypt DynamoDB-formatted JSON.
212
221
213
222
boto3 DynamoDB clients return items formatted as DynamoDB JSON:
223
+
214
224
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html
225
+
215
226
Use this method to decrypt an item if you retrieved the encrypted item
216
- from a boto3 DynamoDB client.
227
+ from a boto3 DynamoDB client.
217
228
(Alternatively, you can use this library's EncryptedClient interface
218
- to transparently decrypt items without an intermediary ItemEncryptor.)
229
+ to transparently decrypt items without an intermediary ItemEncryptor.)
219
230
220
231
Args:
221
232
encrypted_dynamodb_item (dict[str, dict[str, Any]]): The item to decrypt formatted as DynamoDB JSON.
222
233
223
234
Returns:
224
235
DecryptItemOutput: Structure containing the following fields:
225
- - `plaintext_item` (dict[str, Any]): The plaintext DynamoDB item formatted as DynamoDB JSON.
226
- - `parsed_header` (Optional[ParsedHeader]): The decrypted DynamoDB item's header (`aws_dbe_head` value).
236
+
237
+ - plaintext_item (dict[str, Any]): The plaintext DynamoDB item formatted as DynamoDB JSON.
238
+ - parsed_header (Optional[ParsedHeader]): The decrypted DynamoDB item's header (`aws_dbe_head` value).
227
239
228
240
Example:
229
- >>> encrypted_item = {
230
- ... 'some': {'B': b'ENCRYPTED_DATA'},
231
- ... 'more': {'B': b'ENCRYPTED_DATA'}
232
- ... }
233
- >>> decrypt_output = item_encryptor.decrypt_dynamodb_item(encrypted_item)
234
- >>> plaintext_item = decrypt_output.plaintext_item
235
- >>> header = decrypt_output.parsed_header
241
+ >>> encrypted_item = {
242
+ ... 'some': {'B': b'ENCRYPTED_DATA'},
243
+ ... 'more': {'B': b'ENCRYPTED_DATA'}
244
+ ... }
245
+ >>> decrypt_output = item_encryptor.decrypt_dynamodb_item(encrypted_item)
246
+ >>> plaintext_item = decrypt_output.plaintext_item
247
+ >>> header = decrypt_output.parsed_header
236
248
237
249
"""
238
250
return self .decrypt_item (DecryptItemInput (encrypted_item = encrypted_dynamodb_item ))
@@ -245,29 +257,31 @@ def decrypt_item(
245
257
Decrypt a DynamoDB item.
246
258
247
259
The input item should contain a dictionary formatted as DynamoDB JSON:
260
+
248
261
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html
249
262
250
263
Args:
251
264
decrypt_item_input (DecryptItemInput): Structure containing the following field:
252
- - ` encrypted_item` (dict[str, Any]): The item to decrypt formatted as DynamoDB JSON.
265
+ - encrypted_item (dict[str, Any]): The item to decrypt formatted as DynamoDB JSON.
253
266
254
267
Returns:
255
268
DecryptItemOutput: Structure containing the following fields:
256
- - `plaintext_item` (dict[str, Any]): The decrypted DynamoDB item formatted as DynamoDB JSON.
257
- - `parsed_header` (Optional[ParsedHeader]): The decrypted DynamoDB item's header (`aws_dbe_head` value).
269
+
270
+ - plaintext_item (dict[str, Any]): The decrypted DynamoDB item formatted as DynamoDB JSON.
271
+ - parsed_header (Optional[ParsedHeader]): The decrypted DynamoDB item's header (`aws_dbe_head` value).
258
272
259
273
Example:
260
- >>> encrypted_item = {
261
- ... 'some': {'B': b'ENCRYPTED_DATA'},
262
- ... 'more': {'B': b'ENCRYPTED_DATA'}
263
- ... }
264
- >>> decrypted_item = item_encryptor.decrypt_item(
265
- ... DecryptItemInput(
266
- ... encrypted_item = encrypted_item,
267
- ... )
268
- ... )
269
- >>> plaintext_item = decrypted_item.plaintext_item
270
- >>> header = decrypted_item.parsed_header
274
+ >>> encrypted_item = {
275
+ ... 'some': {'B': b'ENCRYPTED_DATA'},
276
+ ... 'more': {'B': b'ENCRYPTED_DATA'}
277
+ ... }
278
+ >>> decrypted_item = item_encryptor.decrypt_item(
279
+ ... DecryptItemInput(
280
+ ... encrypted_item = encrypted_item,
281
+ ... )
282
+ ... )
283
+ >>> plaintext_item = decrypted_item.plaintext_item
284
+ >>> header = decrypted_item.parsed_header
271
285
272
286
"""
273
287
return self ._internal_client .decrypt_item (decrypt_item_input )
0 commit comments