S3 Buckets
All functionalities to deal with AWS S3 Buckets.
Check
Check S3 bucket.
- s3_tools.buckets.check.bucket_exists(bucket: str, aws_auth: Dict[str, str] = {}) bool [source]
Check if a bucket exists.
- Parameters:
bucket (str) – Bucket name to be checked.
aws_auth (Dict[str, str]) – Contains AWS credentials, by default is empty.
- Returns:
True if the bucket exists, otherwise False.
- Return type:
bool
- Raises:
Exception – Any problem with the request is raised.
Example
>>> bucket_exists("myBucket") True
Create
Create S3 Bucket.
- s3_tools.buckets.create.create_bucket(name: str, configs: Dict[str, str] = {}, aws_auth: Dict[str, str] = {}) bool [source]
Create an S3 bucket.
- Parameters:
name (str) – Name of the bucket to create.
configs (Dict[str, str]) – Bucket configurations, by default is empty. To know more about it check boto3 documentation.
aws_auth (Dict[str, str]) – Contains AWS credentials, by default is empty.
- Returns:
True if the bucket was created, False otherwise.
- Return type:
bool
Examples
>>> create_bucket("myBucket") True
Delete
Delete S3 bucket.
- s3_tools.buckets.delete.delete_bucket(name: str, aws_auth: Dict[str, str] = {}) bool [source]
Delete an S3 bucket.
- Parameters:
name (str) – Name of the bucket to delete.
aws_auth (Dict[str, str], optional) – Contains AWS credentials, by default {}
- Returns:
True if the bucket was deleted, False otherwise.
- Return type:
bool
- Raises:
Exception – Any problem with the request is raised.
Examples
>>> delete_bucket("myBucket") True
List
List S3 Buckets.
- s3_tools.buckets.list.list_buckets(search_str: Optional[str] = None, aws_auth: Dict[str, str] = {}) List[str] [source]
Retrieve the list of buckets from AWS S3 filtered by search string.
- Parameters:
search_str (str) – Basic search string to filter out buckets on result (uses Unix shell-style wildcards), by default is None. For more about the search check “fnmatch” package.
aws_auth (Dict[str, str]) – Contains AWS credentials, by default is empty.
- Returns:
List of bucket names filtered.
- Return type:
List[str]
Examples
>>> list_buckets() [ "myRawData", "myProcessedData", "myFinalData"]
>>> list_buckets(search_str="*Raw*") [ "myRawData" ]