2020 ddb_to_dict ,
2121)
2222
23+
2324class ItemEncryptor :
2425 """Class providing item-level encryption for DynamoDB items / Python dictionaries."""
2526
@@ -35,7 +36,7 @@ def __init__(
3536 Parameters:
3637 item_encryptor_config (DynamoDbItemEncryptorConfig): Encryption configuration object.
3738 """
38- self ._internal_client = DynamoDbItemEncryptor (config = item_encryptor_config )
39+ self ._internal_client = DynamoDbItemEncryptor (config = item_encryptor_config )
3940
4041 def encrypt_python_item (
4142 self ,
@@ -60,15 +61,15 @@ def encrypt_python_item(
6061
6162 Parameters:
6263 plaintext_dict_item (dict[str, Any]): A standard Python dictionary.
63-
64+
6465 Returns:
6566 EncryptItemOutput: Structure containing the following fields:
6667 - `encrypted_item` (dict[str, Any]): The encrypted Python dictionary.
6768 **Note:** The item was encrypted as DynamoDB JSON, then transformed to a Python dictionary.
6869 - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header (parsed `aws_dbe_head` value).
6970
7071 Example:
71-
72+
7273 >>> plaintext_item = {
7374 ... 'some': 'data',
7475 ... 'more': 5
@@ -78,11 +79,13 @@ def encrypt_python_item(
7879 >>> header = encrypt_output.parsed_header
7980 """
8081 plaintext_ddb_item = dict_to_ddb (plaintext_dict_item )
81- encrypted_ddb_item : EncryptItemOutput = self .encrypt_dynamodb_item (plaintext_ddb_item )
82+ encrypted_ddb_item : EncryptItemOutput = self .encrypt_dynamodb_item (
83+ plaintext_ddb_item
84+ )
8285 encrypted_dict_item = ddb_to_dict (encrypted_ddb_item .encrypted_item )
8386 return EncryptItemOutput (
84- encrypted_item = encrypted_dict_item ,
85- parsed_header = encrypted_ddb_item .parsed_header
87+ encrypted_item = encrypted_dict_item ,
88+ parsed_header = encrypted_ddb_item .parsed_header ,
8689 )
8790
8891 def encrypt_dynamodb_item (
@@ -101,15 +104,15 @@ def encrypt_dynamodb_item(
101104
102105 Parameters:
103106 plaintext_dynamodb_item (dict[str, dict[str, Any]]): The item to encrypt formatted as DynamoDB JSON.
104-
107+
105108 Returns:
106109 EncryptItemOutput: Structure containing the following fields:
107110 - `encrypted_item` (dict[str, Any]): A dictionary containing the encrypted DynamoDB item
108111 formatted as DynamoDB JSON.
109112 - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header (`aws_dbe_head` value).
110113
111114 Example:
112-
115+
113116 >>> plaintext_item = {
114117 ... 'some': {'S': 'data'},
115118 ... 'more': {'N': '5'}
@@ -119,9 +122,7 @@ def encrypt_dynamodb_item(
119122 >>> header = encrypt_output.parsed_header
120123 """
121124 return self .encrypt_item (
122- EncryptItemInput (
123- plaintext_item = plaintext_dynamodb_item
124- )
125+ EncryptItemInput (plaintext_item = plaintext_dynamodb_item )
125126 )
126127
127128 def encrypt_item (
@@ -137,14 +138,14 @@ def encrypt_item(
137138 Parameters:
138139 encrypt_item_input (EncryptItemInput): Structure containing the following field:
139140 - `plaintext_item` (dict[str, Any]): The item to encrypt formatted as DynamoDB JSON.
140-
141+
141142 Returns:
142143 EncryptItemOutput: Structure containing the following fields:
143144 - `encrypted_item` (dict[str, Any]): The encrypted DynamoDB item formatted as DynamoDB JSON.
144145 - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header (`aws_dbe_head` value).
145146
146147 Example:
147-
148+
148149 >>> plaintext_item = {
149150 ... 'some': {'S': 'data'},
150151 ... 'more': {'N': '5'}
@@ -182,15 +183,15 @@ def decrypt_python_item(
182183
183184 Parameters:
184185 encrypted_dict_item (dict[str, Any]): A standard Python dictionary with encrypted values.
185-
186+
186187 Returns:
187188 DecryptItemOutput: Structure containing the following fields:
188189 - `plaintext_item` (dict[str, Any]): The decrypted Python dictionary.
189190 **Note:** The item was decrypted as DynamoDB JSON, then transformed to a Python dictionary.
190191 - `parsed_header` (Optional[ParsedHeader]): The encrypted DynamoDB item's header (parsed `aws_dbe_head` value).
191192
192193 Example:
193-
194+
194195 >>> encrypted_item = {
195196 ... 'some': b'ENCRYPTED_DATA',
196197 ... 'more': b'ENCRYPTED_DATA',
@@ -200,11 +201,13 @@ def decrypt_python_item(
200201 >>> header = decrypt_output.parsed_header
201202 """
202203 encrypted_ddb_item = dict_to_ddb (encrypted_dict_item )
203- plaintext_ddb_item : DecryptItemOutput = self .decrypt_dynamodb_item (encrypted_ddb_item )
204+ plaintext_ddb_item : DecryptItemOutput = self .decrypt_dynamodb_item (
205+ encrypted_ddb_item
206+ )
204207 plaintext_dict_item = ddb_to_dict (plaintext_ddb_item .plaintext_item )
205208 return DecryptItemOutput (
206- plaintext_item = plaintext_dict_item ,
207- parsed_header = plaintext_ddb_item .parsed_header
209+ plaintext_item = plaintext_dict_item ,
210+ parsed_header = plaintext_ddb_item .parsed_header ,
208211 )
209212
210213 def decrypt_dynamodb_item (
@@ -223,14 +226,14 @@ def decrypt_dynamodb_item(
223226
224227 Parameters:
225228 encrypted_ddb_item (dict[str, dict[str, Any]]): The item to decrypt formatted as DynamoDB JSON.
226-
229+
227230 Returns:
228231 DecryptItemOutput: Structure containing the following fields:
229232 - `plaintext_item` (dict[str, Any]): The plaintext DynamoDB item formatted as DynamoDB JSON.
230233 - `parsed_header` (Optional[ParsedHeader]): The decrypted DynamoDB item's header (`aws_dbe_head` value).
231234
232235 Example:
233-
236+
234237 >>> encrypted_item = {
235238 ... 'some': {'B': b'ENCRYPTED_DATA'},
236239 ... 'more': {'B': b'ENCRYPTED_DATA'}
@@ -240,9 +243,7 @@ def decrypt_dynamodb_item(
240243 >>> header = decrypt_output.parsed_header
241244 """
242245 return self .decrypt_item (
243- DecryptItemInput (
244- encrypted_item = encrypted_dynamodb_item
245- )
246+ DecryptItemInput (encrypted_item = encrypted_dynamodb_item )
246247 )
247248
248249 def decrypt_item (
@@ -258,14 +259,14 @@ def decrypt_item(
258259 Parameters:
259260 decrypt_item_input (DecryptItemInput): Structure containing the following field:
260261 - `encrypted_item` (dict[str, Any]): The item to decrypt formatted as DynamoDB JSON.
261-
262+
262263 Returns:
263264 DecryptItemOutput: Structure containing the following fields:
264265 - `plaintext_item` (dict[str, Any]): The decrypted DynamoDB item formatted as DynamoDB JSON.
265266 - `parsed_header` (Optional[ParsedHeader]): The decrypted DynamoDB item's header (`aws_dbe_head` value).
266267
267268 Example:
268-
269+
269270 >>> encrypted_item = {
270271 ... 'some': {'B': b'ENCRYPTED_DATA'},
271272 ... 'more': {'B': b'ENCRYPTED_DATA'}
0 commit comments