Skip to content

Commit eb158dc

Browse files
author
Lucas McDonald
committed
m
1 parent dc59b60 commit eb158dc

File tree

1 file changed

+67
-55
lines changed
  • DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/encrypted

1 file changed

+67
-55
lines changed

DynamoDbEncryption/runtimes/python/src/aws_dbesdk_dynamodb/encrypted/client.py

Lines changed: 67 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ class EncryptedClient(EncryptedBotoInterface):
6969
* ``transact_write_items``
7070
* ``delete_item``
7171
72+
Any calls to ``update_item`` can only update unsigned attributes. If an attribute to be updated is marked as signed,
73+
this operation will raise a ``DynamoDbEncryptionTransformsException``.
74+
7275
The following operations are not supported and will raise DynamoDbEncryptionTransformsException:
7376
7477
* ``execute_statement``
7578
* ``execute_transaction``
7679
* ``batch_execute_statement``
77-
* ``update_item``
7880
7981
Any other operations on this class will defer to the underlying boto3 DynamoDB client's implementation.
8082
@@ -383,6 +385,70 @@ def delete_item(self, **kwargs):
383385
output_item_to_ddb_transform_method=self._resource_to_client_shape_converter.delete_item_response,
384386
)
385387

388+
def update_item(self, **kwargs):
389+
"""
390+
Update an unsigned attribute in an item on a table.
391+
392+
If the attribute is signed, this operation will raise DynamoDbEncryptionTransformsException.
393+
394+
The input and output syntaxes match those for the boto3 DynamoDB client ``update_item`` API:
395+
396+
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/client/update_item.html
397+
398+
Args:
399+
**kwargs: Keyword arguments to pass to the operation. This matches the boto3 client ``update_item``
400+
request syntax.
401+
402+
Returns:
403+
dict: The response from DynamoDB. This matches the boto3 client ``update_item`` response syntax.
404+
405+
Raises:
406+
DynamoDbEncryptionTransformsException: If an attribute specified in the ``UpdateExpression`` is signed.
407+
408+
"""
409+
return self._client_operation_logic(
410+
operation_input=kwargs,
411+
input_item_to_ddb_transform_method=self._resource_to_client_shape_converter.update_item_request,
412+
input_item_to_dict_transform_method=self._client_to_resource_shape_converter.update_item_request,
413+
input_transform_method=self._transformer.update_item_input_transform,
414+
input_transform_shape=UpdateItemInputTransformInput,
415+
output_transform_method=self._transformer.update_item_output_transform,
416+
output_transform_shape=UpdateItemOutputTransformInput,
417+
client_method=self._client.update_item,
418+
output_item_to_dict_transform_method=self._client_to_resource_shape_converter.update_item_response,
419+
output_item_to_ddb_transform_method=self._resource_to_client_shape_converter.update_item_response,
420+
)
421+
422+
def get_paginator(self, operation_name: str) -> EncryptedPaginator | botocore.client.Paginator:
423+
"""
424+
Get a paginator from the underlying client.
425+
426+
If the paginator requested is for "scan" or "query", the paginator returned will
427+
transparently decrypt the returned items.
428+
429+
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#paginators
430+
431+
Args:
432+
operation_name (str): Name of operation for which to get paginator
433+
434+
Returns:
435+
EncryptedPaginator | botocore.client.Paginator: An EncryptedPaginator that will transparently decrypt items
436+
for ``scan``/``query`` operations; for other operations, the standard paginator.
437+
438+
"""
439+
paginator = self._client.get_paginator(operation_name)
440+
441+
if operation_name in ("scan", "query"):
442+
return EncryptedPaginator(
443+
paginator=paginator,
444+
encryption_config=self._encryption_config,
445+
expect_standard_dictionaries=self._expect_standard_dictionaries,
446+
)
447+
else:
448+
# The paginator can still be used for list_backups, list_tables, and list_tags_of_resource,
449+
# but there is nothing to encrypt/decrypt in these operations.
450+
return paginator
451+
386452
def execute_statement(self, **kwargs):
387453
"""
388454
Not implemented. Raises DynamoDbEncryptionTransformsException.
@@ -431,30 +497,6 @@ def execute_transaction(self, **kwargs):
431497
output_item_to_ddb_transform_method=self._resource_to_client_shape_converter.execute_transaction_response,
432498
)
433499

434-
def update_item(self, **kwargs):
435-
"""
436-
Not implemented. Raises DynamoDbEncryptionTransformsException.
437-
438-
Args:
439-
**kwargs: Any arguments passed to this method
440-
441-
Raises:
442-
DynamoDbEncryptionTransformsException: This operation is not supported on encrypted tables.
443-
444-
"""
445-
return self._client_operation_logic(
446-
operation_input=kwargs,
447-
input_item_to_ddb_transform_method=self._resource_to_client_shape_converter.update_item_request,
448-
input_item_to_dict_transform_method=self._client_to_resource_shape_converter.update_item_request,
449-
input_transform_method=self._transformer.update_item_input_transform,
450-
input_transform_shape=UpdateItemInputTransformInput,
451-
output_transform_method=self._transformer.update_item_output_transform,
452-
output_transform_shape=UpdateItemOutputTransformInput,
453-
client_method=self._client.update_item,
454-
output_item_to_dict_transform_method=self._client_to_resource_shape_converter.update_item_response,
455-
output_item_to_ddb_transform_method=self._resource_to_client_shape_converter.update_item_response,
456-
)
457-
458500
def batch_execute_statement(self, **kwargs):
459501
"""
460502
Not implemented. Raises DynamoDbEncryptionTransformsException.
@@ -479,36 +521,6 @@ def batch_execute_statement(self, **kwargs):
479521
output_item_to_ddb_transform_method=self._resource_to_client_shape_converter.batch_execute_statement_response,
480522
)
481523

482-
def get_paginator(self, operation_name: str) -> EncryptedPaginator | botocore.client.Paginator:
483-
"""
484-
Get a paginator from the underlying client.
485-
486-
If the paginator requested is for "scan" or "query", the paginator returned will
487-
transparently decrypt the returned items.
488-
489-
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#paginators
490-
491-
Args:
492-
operation_name (str): Name of operation for which to get paginator
493-
494-
Returns:
495-
EncryptedPaginator | botocore.client.Paginator: An EncryptedPaginator that will transparently decrypt items
496-
for ``scan``/``query`` operations; for other operations, the standard paginator.
497-
498-
"""
499-
paginator = self._client.get_paginator(operation_name)
500-
501-
if operation_name in ("scan", "query"):
502-
return EncryptedPaginator(
503-
paginator=paginator,
504-
encryption_config=self._encryption_config,
505-
expect_standard_dictionaries=self._expect_standard_dictionaries,
506-
)
507-
else:
508-
# The paginator can still be used for list_backups, list_tables, and list_tags_of_resource,
509-
# but there is nothing to encrypt/decrypt in these operations.
510-
return paginator
511-
512524
def _client_operation_logic(
513525
self,
514526
*,

0 commit comments

Comments
 (0)