16 from botocore.client
import Config
17 from botocore.exceptions
import ClientError
24 's3', region_name=region_name, config=Config(signature_version=_SIGV4_NAME))
25 self.
s3_resource = boto3.resource(
's3', region_name=region_name)
29 response = self.s3_client.create_bucket(
31 CreateBucketConfiguration={
35 return response[
'Location']
38 self.s3_client.delete_bucket(
43 bucket = self.s3_resource.Bucket(bucket_name)
44 bucket.objects.all().delete()
47 objects_to_delete = []
49 objects_to_delete.append({
52 self.s3_client.delete_objects(
55 'Objects': objects_to_delete
60 response = self.s3_client.list_objects(Bucket=bucket_name)
61 return response.get(
'Contents', [])
64 waiter = self.s3_client.get_waiter(
'bucket_exists')
65 waiter.wait(Bucket=bucket_name)
68 self.s3_client.download_file(
def create_bucket(self, bucket_name)
def __init__(self, region_name)
def delete_bucket(self, bucket_name)
def delete_all_objects(self, bucket_name)
def wait_for_bucket_create(self, bucket_name)
def delete_objects(self, bucket_name, keys)
def list_objects(self, bucket_name)
def download_file(self, bucket_name, key, file_name)