dynamodb_encryption_sdk.internal.utils

Otherwise undifferentiated utility resources.

Warning

No guarantee is provided on the modules and APIs within this namespace staying consistent. Directly reference at your own risk.

Functions

crypto_config_from_cache(materials_provider, ...)

Build a crypto config from the provided values, loading the table info from the provided cache.

crypto_config_from_kwargs(fallback, **kwargs)

Pull all encryption-specific parameters from the request and use them to build a crypto config.

crypto_config_from_table_info(...)

Build a crypto config from the provided values and table info.

decrypt_batch_get_item(decrypt_method, ...)

Transparently decrypt multiple items after getting them in a batch request.

decrypt_get_item(decrypt_method, ...)

Transparently decrypt an item after getting it from the table.

decrypt_list_of_items(crypto_config, ...)

Iterate through a list of encrypted items, decrypting each item and yielding the plaintext item.

decrypt_multi_get(decrypt_method, ...)

Transparently decrypt multiple items after getting them from the table with a scan or query method.

encrypt_batch_write_item(encrypt_method, ...)

Transparently encrypt multiple items before putting them in a batch request.

encrypt_put_item(encrypt_method, ...)

Transparently encrypt an item before putting it to the table.

validate_get_arguments(kwargs)

Verify that attribute filtering parameters are not found in the request.

Classes

TableInfoCache(client, ...)

Very simple cache of TableInfo objects, providing configuration information about DynamoDB tables.

class dynamodb_encryption_sdk.internal.utils.TableInfoCache(client: botocore.client.BaseClient, auto_refresh_table_indexes: bool)[source]

Bases: object

Very simple cache of TableInfo objects, providing configuration information about DynamoDB tables.

Parameters
  • client (botocore.client.BaseClient) – Boto3 DynamoDB client

  • auto_refresh_table_indexes (bool) – Should we attempt to refresh information about table indexes? Requires dynamodb:DescribeTable permissions on each table.

table_info(table_name)[source]

Collect a TableInfo object for the specified table, creating and adding it to the cache if not already present.

Parameters

table_name (str) – Name of table

Returns

TableInfo describing the requested table

Return type

TableInfo

dynamodb_encryption_sdk.internal.utils.crypto_config_from_kwargs(fallback, **kwargs)[source]

Pull all encryption-specific parameters from the request and use them to build a crypto config.

Returns

crypto config and updated kwargs

Return type

dynamodb_encryption_sdk.encrypted.CryptoConfig and dict

dynamodb_encryption_sdk.internal.utils.crypto_config_from_table_info(materials_provider, attribute_actions, table_info)[source]

Build a crypto config from the provided values and table info.

Returns

crypto config and updated kwargs

Return type

tuple(CryptoConfig, dict)

dynamodb_encryption_sdk.internal.utils.crypto_config_from_cache(materials_provider, attribute_actions, table_info_cache, table_name)[source]

Build a crypto config from the provided values, loading the table info from the provided cache.

Returns

crypto config and updated kwargs

Return type

tuple(CryptoConfig, dict)

dynamodb_encryption_sdk.internal.utils.decrypt_get_item(decrypt_method: Callable, crypto_config_method: Callable, read_method: Callable, **kwargs: Any) Dict[source]

Transparently decrypt an item after getting it from the table.

Parameters
  • decrypt_method (callable) – Method to use to decrypt item

  • crypto_config_method (callable) – Method that accepts kwargs and provides a CryptoConfig

  • read_method (callable) – Method that reads from the table

  • **kwargs – Keyword arguments to pass to read_method

Returns

DynamoDB response

Return type

dict

dynamodb_encryption_sdk.internal.utils.decrypt_multi_get(decrypt_method: Callable, crypto_config_method: Callable, read_method: Callable, **kwargs: Any) Dict[source]

Transparently decrypt multiple items after getting them from the table with a scan or query method.

Parameters
  • decrypt_method (callable) – Method to use to decrypt items

  • crypto_config_method (callable) – Method that accepts kwargs and provides a CryptoConfig

  • read_method (callable) – Method that reads from the table

  • **kwargs – Keyword arguments to pass to read_method

Returns

DynamoDB response

Return type

dict

dynamodb_encryption_sdk.internal.utils.decrypt_list_of_items(crypto_config: CryptoConfig, decrypt_method: Callable, items: Iterable[Any]) Iterable[Any][source]

Iterate through a list of encrypted items, decrypting each item and yielding the plaintext item.

Parameters
  • crypto_config (CryptoConfig) – CryptoConfig to use

  • decrypt_method (callable) – Method to use to decrypt items

  • items – Iterable of encrypted items

Returns

Iterable of plaintext items

dynamodb_encryption_sdk.internal.utils.decrypt_batch_get_item(decrypt_method: Callable, crypto_config_method: Callable, read_method: Callable, **kwargs: Any) Dict[source]

Transparently decrypt multiple items after getting them in a batch request.

Parameters
  • decrypt_method (callable) – Method to use to decrypt items

  • crypto_config_method (callable) – Method that accepts kwargs and provides a CryptoConfig

  • read_method (callable) – Method that reads from the table

  • **kwargs – Keyword arguments to pass to read_method

Returns

DynamoDB response

Return type

dict

dynamodb_encryption_sdk.internal.utils.encrypt_put_item(encrypt_method: Callable, crypto_config_method: Callable, write_method: Callable, **kwargs: Any) Dict[source]

Transparently encrypt an item before putting it to the table.

Parameters
  • encrypt_method (callable) – Method to use to encrypt items

  • crypto_config_method (callable) – Method that accepts kwargs and provides a CryptoConfig

  • write_method (callable) – Method that writes to the table

  • **kwargs – Keyword arguments to pass to write_method

Returns

DynamoDB response

Return type

dict

dynamodb_encryption_sdk.internal.utils.encrypt_batch_write_item(encrypt_method: Callable, crypto_config_method: Callable, write_method: Callable, **kwargs: Any) Dict[source]

Transparently encrypt multiple items before putting them in a batch request.

Parameters
  • encrypt_method (callable) – Method to use to encrypt items

  • crypto_config_method (callable) – Method that accepts a table name string and provides a CryptoConfig

  • write_method (callable) – Method that writes to the table

  • **kwargs – Keyword arguments to pass to write_method

Returns

DynamoDB response

Return type

dict

dynamodb_encryption_sdk.internal.utils.validate_get_arguments(kwargs: Dict[Text, Any]) None[source]

Verify that attribute filtering parameters are not found in the request.

Raises

InvalidArgumentError – if banned parameters are found