S3 Persistence Adapter¶
S3 Persistence Adapter¶
-
class
ask_sdk_s3.adapter.
S3Adapter
(bucket_name, path_prefix=None, s3_client=None, object_keygen=<function user_id_keygen>)¶ Bases:
ask_sdk_core.attributes_manager.AbstractPersistenceAdapter
Persistence Adapter implementation using AmazonS3.
Amazon S3 based persistence adapter implementation. This internally uses the AWS Python SDK (boto3) to process the s3 operations.
Parameters: - bucket_name (str) – S3 bucket name to be used.
- path_prefix (str) – S3 path prefix
- s3_client (boto3.client) – S3 Client to be used. Defaulted to the s3 client generated from boto3.
- object_keygen (Callable[[ask_sdk_model.request_envelope.RequestEnvelope], str]) – Callable function that takes a request envelope and provides a unique key value. Defaulted to user id keygen function.
-
DEFAULT_PATH_PREFIX
= ''¶
-
S3_CLIENT_NAME
= 's3'¶
-
S3_OBJECT_BODY_NAME
= 'Body'¶
-
delete_attributes
(request_envelope)¶ Deletes attributes from s3 bucket.
Parameters: request_envelope (ask_sdk_model.request_envelope.RequestEnvelope) – Request Envelope passed during skill invocation Return type: None Raises: ask_sdk_core.exceptions.PersistenceException
-
get_attributes
(request_envelope)¶ Retrieves the attributes from s3 bucket.
Parameters: request_envelope (ask_sdk_model.request_envelope.RequestEnvelope) – Request Envelope passed during skill invocation Returns: attributes in the s3 bucket Return type: Dict[str, object] Raises: ask_sdk_core.exceptions.PersistenceException
-
save_attributes
(request_envelope, attributes)¶ Saves attributes to the s3 bucket.
Parameters: - request_envelope (ask_sdk_model.request_envelope.RequestEnvelope) – Request Envelope passed during skill invocation
- attributes (Dict[str, object]) – attributes to store in s3
Return type: Raises:
Object Key Generator Functions¶
-
ask_sdk_s3.object_keygen.
device_id_keygen
(request_envelope)¶ Retrieve device id from request envelope.
Parameters: request_envelope (ask_sdk_model.RequestEnvelope) – Request Envelope passed during skill invocation Returns: Device Id retrieved from request envelope Return type: str Raises: ask_sdk_core.exceptions.PersistenceException
-
ask_sdk_s3.object_keygen.
user_id_keygen
(request_envelope)¶ Retrieve user id from request envelope, to use as object key.
Parameters: request_envelope (ask_sdk_model.RequestEnvelope) – Request Envelope passed during skill invocation Returns: User Id retrieved from request envelope Return type: str Raises: ask_sdk_core.exceptions.PersistenceException