Package com.exasol.spark.s3
Class S3FileSystem
- java.lang.Object
-
- com.exasol.spark.s3.S3FileSystem
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public final class S3FileSystem extends Object implements Closeable
An S3 file system operations implementations.
-
-
Constructor Summary
Constructors Constructor Description S3FileSystem(software.amazon.awssdk.services.s3.S3Client s3Client)
Creates a new instance ofS3FileSystem
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
deleteBucket(String bucketName)
Deletes a given bucket.void
deleteKeys(String bucketName, String bucketKey)
For a bucket with given name: delete all contents with the specified key.boolean
doesBucketExist(String bucketName)
Checks if a given bucket exists.static S3FileSystem
fromOptions(com.exasol.spark.common.ExasolOptions options)
Creates a new instance ofS3FileSystem
fromExasolOptions
options.boolean
isEmpty(String bucketName, Optional<String> bucketKey)
Checks if a given bucket with optional bucket key is empty.List<software.amazon.awssdk.services.s3.model.S3Object>
listObjects(String bucketName, Optional<String> bucketKey)
Lists objects in a given bucket with optional bucket key.
-
-
-
Constructor Detail
-
S3FileSystem
public S3FileSystem(software.amazon.awssdk.services.s3.S3Client s3Client)
Creates a new instance ofS3FileSystem
.- Parameters:
s3Client
- s3 client object
-
-
Method Detail
-
fromOptions
public static S3FileSystem fromOptions(com.exasol.spark.common.ExasolOptions options)
Creates a new instance ofS3FileSystem
fromExasolOptions
options.- Parameters:
options
- user provided options- Returns:
- new instance of
S3FileSystem
-
doesBucketExist
public boolean doesBucketExist(String bucketName)
Checks if a given bucket exists.- Parameters:
bucketName
- name of a bucket- Returns:
true
if bucket exists,false
otherwise
-
deleteBucket
public void deleteBucket(String bucketName)
Deletes a given bucket.- Parameters:
bucketName
- name of a bucket
-
deleteKeys
public void deleteKeys(String bucketName, String bucketKey)
For a bucket with given name: delete all contents with the specified key.- Parameters:
bucketName
- name of a bucketbucketKey
- bucket key value
-
listObjects
public List<software.amazon.awssdk.services.s3.model.S3Object> listObjects(String bucketName, Optional<String> bucketKey)
Lists objects in a given bucket with optional bucket key.- Parameters:
bucketName
- name of a bucketbucketKey
- optional bucket key- Returns:
- list of objects in a bucket
-
isEmpty
public boolean isEmpty(String bucketName, Optional<String> bucketKey)
Checks if a given bucket with optional bucket key is empty.- Parameters:
bucketName
- name of a bucketbucketKey
- optional bucket key- Returns:
true
if bucket is empty,false
otherwise
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-