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