aws_dbesdk_dynamodb.encrypted.client
High-level helper class to provide an encrypting wrapper for boto3 DynamoDB clients.
Classes
|
Wrapper for a boto3 DynamoDB client that transparently encrypts/decrypts items. |
- class aws_dbesdk_dynamodb.encrypted.client.EncryptedClient(*, client: BaseClient, encryption_config: DynamoDbTablesEncryptionConfig, expect_standard_dictionaries: bool | None = False)
Bases:
EncryptedBotoInterfaceWrapper for a boto3 DynamoDB client that transparently encrypts/decrypts items.
This class implements the complete boto3 DynamoDB client API, allowing it to serve as a drop-in replacement that transparently handles encryption and decryption of items.
The API matches the standard boto3 DynamoDB client interface:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#client
This class will encrypt/decrypt items for the following operations:
put_itemget_itemqueryscanbatch_write_itembatch_get_itemtransact_get_itemstransact_write_itemsdelete_item
Any calls to
update_itemcan only update unsigned attributes. If an attribute to be updated is marked as signed, this operation will raise aDynamoDbEncryptionTransformsException.The following operations are not supported for encrypted tables:
execute_statementexecute_transactionbatch_execute_statement
Calling these operations for encrypted tables will raise a
DynamoDbEncryptionTransformsException. This client can still be used to call these operations on plaintext tables.Any other operations on this class will defer to the underlying boto3 DynamoDB client’s implementation.
EncryptedClientcan also return anEncryptedPaginatorfor transparent decryption of paginated results.Create an
EncryptedClientobject.- Parameters:
client (botocore.client.BaseClient) – Initialized boto3 DynamoDB client
encryption_config (DynamoDbTablesEncryptionConfig) – Initialized DynamoDbTablesEncryptionConfig
expect_standard_dictionaries (Optional[bool]) – Does the underlying boto3 client expect items to be standard Python dictionaries? This should only be set to True if you are using a client obtained from a service resource or table resource (ex:
table.meta.client). If this is True,EncryptedClientwill expect item-like shapes to be standard Python dictionaries (default: False).
- __init__(*, client: BaseClient, encryption_config: DynamoDbTablesEncryptionConfig, expect_standard_dictionaries: bool | None = False)
Create an
EncryptedClientobject.- Parameters:
client (botocore.client.BaseClient) – Initialized boto3 DynamoDB client
encryption_config (DynamoDbTablesEncryptionConfig) – Initialized DynamoDbTablesEncryptionConfig
expect_standard_dictionaries (Optional[bool]) – Does the underlying boto3 client expect items to be standard Python dictionaries? This should only be set to True if you are using a client obtained from a service resource or table resource (ex:
table.meta.client). If this is True,EncryptedClientwill expect item-like shapes to be standard Python dictionaries (default: False).
- put_item(**kwargs) dict[str, Any]
Put a single item to a table. Encrypts the item before writing to DynamoDB.
The input and output syntaxes match those for the boto3 DynamoDB
put_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
put_itemrequest syntax. The value in"Item"will be encrypted locally before being written to DynamoDB.- Returns:
The response from DynamoDB. This matches the boto3 client
put_itemresponse syntax.- Return type:
- get_item(**kwargs) dict[str, Any]
Get a single item from a table. Decrypts the item after reading from DynamoDB.
The input and output syntaxes match those for the boto3 DynamoDB
get_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
get_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
get_itemresponse syntax. The value in"Item"field be decrypted locally after being read from DynamoDB.- Return type:
- query(**kwargs) dict[str, Any]
Query items from a table or index. Decrypts any returned items.
The input and output syntaxes match those for the boto3 DynamoDB client
queryAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. These match the boto3 query API parameters.
- Returns:
- The response from DynamoDB. This matches the boto3 client
queryAPI response. The
"Items"field will be decrypted locally after being read from DynamoDB.
- The response from DynamoDB. This matches the boto3 client
- Return type:
- scan(**kwargs) dict[str, Any]
Scan an entire table or index. Decrypts any returned items.
The input and output syntaxes match those for the boto3 DynamoDB
scanAPI:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb/client/scan.html
- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
scanrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
scanresponse syntax. The values in"Items"will be decrypted locally after being read from DynamoDB.- Return type:
- batch_write_item(**kwargs) dict[str, Any]
Put or delete multiple items in one or more tables.
For put operations, encrypts items before writing.
The input and output syntaxes match those for the boto3 DynamoDB
batch_write_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
batch_write_itemrequest syntax. Items in"PutRequest"values in the"RequestItems"argument will be encrypted locally before being written to DynamoDB.- Returns:
The response from DynamoDB. This matches the boto3 client
batch_write_itemresponse syntax.- Return type:
- batch_get_item(**kwargs) dict[str, Any]
Get multiple items from one or more tables. Decrypts any returned items.
The input and output syntaxes match those for the boto3 DynamoDB
batch_get_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3
batch_get_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
batch_get_itemresponse syntax. The values in"Responses"will be decrypted locally after being read from DynamoDB.- Return type:
- transact_get_items(**kwargs) dict[str, Any]
Get multiple items in a single transaction. Decrypts any returned items.
The input and output syntaxes match those for the boto3 DynamoDB
transact_get_itemsAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
transact_get_itemsrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
transact_get_itemsresponse syntax.- Return type:
- transact_write_items(**kwargs) dict[str, Any]
Perform multiple write operations in a single transaction.
For put operations, encrypts items before writing.
The input and output syntaxes match those for the boto3 DynamoDB client
transact_write_itemsAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
transact_write_itemsrequest syntax. Any"PutRequest"values in the"TransactItems"argument will be encrypted locally before being written to DynamoDB.- Returns:
The response from DynamoDB. This matches the boto3 client
transact_write_itemsresponse syntax.- Return type:
- delete_item(**kwargs)
Delete an item from a table by the specified key.
The input and output syntaxes match those for the boto3 DynamoDB client
delete_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
delete_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
delete_itemresponse syntax. Any values in the"Attributes"field will be decrypted locally after being read from DynamoDB.- Return type:
- update_item(**kwargs)
Update an unsigned attribute in an item on a table.
If the attribute is signed, this operation will raise DynamoDbEncryptionTransformsException.
The input and output syntaxes match those for the boto3 DynamoDB client
update_itemAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
update_itemrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
update_itemresponse syntax.- Return type:
- Raises:
DynamoDbEncryptionTransformsException – If an attribute specified in the
UpdateExpressionis signed.
- execute_statement(**kwargs)
Call
execute_statementon the underlying client if the table is not configured for encryption.If the table is configured for encryption, this operation will raise DynamoDbEncryptionTransformsException.
The input and output syntaxes match those for the boto3 DynamoDB client
execute_statementAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
execute_statementrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
execute_statementresponse syntax.- Return type:
- Raises:
DynamoDbEncryptionTransformsException – If this operation is called for an encrypted table.
- execute_transaction(**kwargs)
Call
execute_transactionon the underlying client if the table is not configured for encryption.If the table is configured for encryption, this operation will raise DynamoDbEncryptionTransformsException.
The input and output syntaxes match those for the boto3 DynamoDB client
execute_transactionAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
execute_transactionrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
execute_transactionresponse syntax.- Return type:
- Raises:
DynamoDbEncryptionTransformsException – If this operation is called for an encrypted table.
- batch_execute_statement(**kwargs)
Call
batch_execute_statementon the underlying client if the table is not configured for encryption.If the table is configured for encryption, this operation will raise DynamoDbEncryptionTransformsException.
The input and output syntaxes match those for the boto3 DynamoDB client
batch_execute_statementAPI:- Parameters:
**kwargs – Keyword arguments to pass to the operation. This matches the boto3 client
batch_execute_statementrequest syntax.- Returns:
The response from DynamoDB. This matches the boto3 client
batch_execute_statementresponse syntax.- Return type:
- Raises:
DynamoDbEncryptionTransformsException – If this operation is called for an encrypted table.
- get_paginator(operation_name: str) EncryptedPaginator | Paginator
Get a paginator from the underlying client.
If the paginator requested is for “scan” or “query”, the paginator returned will transparently decrypt the returned items.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#paginators
- Parameters:
operation_name (str) – Name of operation for which to get paginator
- Returns:
An EncryptedPaginator that will transparently decrypt items for
scan/queryoperations; for other operations, the standard paginator.- Return type:
EncryptedPaginator | botocore.client.Paginator