aws_codeseeder.services.s3

Module Contents

Functions

copy_s3_object(src_bucket: str, src_key: str, dest_bucket: str, dest_key: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Copy an S3 Object to another bucket

delete_bucket(bucket: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Delete an S3 Bucket

delete_bucket_by_prefix(prefix: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Delete S3 Buckets whose name begins with a prefix

delete_objects(bucket: str, keys: Optional[List[str]] = None, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Delete objects from an S3 Bucket

is_bucket_empty(bucket: str, folder: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → bool

Checks if there is any file in a specified folder within an S3 bucket.

list_keys(bucket: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → List[Dict[str, str]]

List the keys/objects in an S3 Buket

list_s3_objects(bucket: str, prefix: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → Dict[str, Any]

List S3 objects in a Bucket filtered to a prefix

object_exists(bucket: str, key: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → bool

Check for existence of an object in an S3 Bucket

upload_file(src: str, bucket: str, key: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) → None

Upload file to S3 Bucket

aws_codeseeder.services.s3.copy_s3_object(src_bucket: str, src_key: str, dest_bucket: str, dest_key: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Copy an S3 Object to another bucket

Parameters
  • src_bucket (str) – Source S3 Bucket

  • src_key (str) – Source Key

  • dest_bucket (str) – Destination S3 Bucket

  • dest_key (str) – Destination Key

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

aws_codeseeder.services.s3.delete_bucket(bucket: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Delete an S3 Bucket

Parameters
  • bucket (str) – S3 Bucket Name

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Raises

ex – If error other that NoSuchBucket

aws_codeseeder.services.s3.delete_bucket_by_prefix(prefix: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Delete S3 Buckets whose name begins with a prefix

Parameters
  • prefix (str) – Prefix to filter Buckets by

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

aws_codeseeder.services.s3.delete_objects(bucket: str, keys: Optional[List[str]] = None, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Delete objects from an S3 Bucket

Parameters
  • bucket (str) – S3 Bucket name

  • keys (Optional[List[str]], optional) – List of keys to delete, all if None, by default None

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

aws_codeseeder.services.s3.is_bucket_empty(bucket: str, folder: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) bool

Checks if there is any file in a specified folder within an S3 bucket.

Parameters: - bucket: The name of the S3 bucket. - folder: The name of the folder inside the bucket.

Returns: - False if the folder contains files, True otherwise.

aws_codeseeder.services.s3.list_keys(bucket: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) List[Dict[str, str]]

List the keys/objects in an S3 Buket

Parameters
  • bucket (str) – S3 Bucket name

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Returns

List of Keys and VersionIds

Return type

List[Dict[str, str]]

aws_codeseeder.services.s3.list_s3_objects(bucket: str, prefix: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) Dict[str, Any]

List S3 objects in a Bucket filtered to a prefix

Parameters
  • bucket (str) – S3 Bucket name

  • prefix (str) – Prefix filter

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Returns

List of objects

Return type

Dict[str, Any]

aws_codeseeder.services.s3.object_exists(bucket: str, key: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) bool

Check for existence of an object in an S3 Bucket

Parameters
  • bucket (str) – S3 Bucket name

  • key (str) – Key to ckeck

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None

Returns

Indicator of object existence

Return type

bool

aws_codeseeder.services.s3.upload_file(src: str, bucket: str, key: str, session: Optional[Union[Callable[[], boto3.Session], boto3.Session]] = None) None

Upload file to S3 Bucket

Parameters
  • src (str) – Local source file

  • bucket (str) – S3 Bucket

  • key (str) – Key name to upload to

  • session (Optional[Union[Callable[[], Session], Session]], optional) – Optional Session or function returning a Session to use for all boto3 operations, by default None