Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add builder support to MinioClient class #987

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
783 changes: 409 additions & 374 deletions api/src/main/java/io/minio/MinioClient.java

Large diffs are not rendered by default.

167 changes: 96 additions & 71 deletions api/src/test/java/io/minio/MinioClientTest.java

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ subprojects {
importOrder 'edu', 'com', 'io', 'java', 'javax', 'org', ''
removeUnusedImports()
googleJavaFormat()
paddedCell()
}
groovyGradle {
target '*.gradle'
Expand Down
252 changes: 107 additions & 145 deletions docs/API.md

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions examples/BucketExists.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Check whether 'my-bucketname' exist or not.
boolean found =
Expand Down
17 changes: 12 additions & 5 deletions examples/ComposeObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ public class ComposeObject {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
/* play.minio.io for test and development. */
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io:9000",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Create a ComposeSource to compose Object.
ComposeSource s1 = new ComposeSource("my-bucketname-one", "my-objectname-one");
Expand Down
17 changes: 12 additions & 5 deletions examples/ComposeObjectEncrypted.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ public class ComposeObjectEncrypted {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
/* play.minio.io for test and development. */
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io:9000",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

byte[] key = "01234567890123456789012345678901".getBytes(StandardCharsets.UTF_8);
SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
Expand Down
15 changes: 9 additions & 6 deletions examples/CopyObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(256);
Expand Down
15 changes: 9 additions & 6 deletions examples/DeleteBucketEncryption.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

minioClient.deleteBucketEncryption(
DeleteBucketEncryptionArgs.builder().bucket("my-bucketname").build());
Expand Down
15 changes: 13 additions & 2 deletions examples/DeleteBucketLifeCycle.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ public class DeleteBucketLifeCycle {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
/* Amazon S3: */
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Pass blank as life cycle in setBucketLifeCycle method.
minioClient.deleteBucketLifeCycle(
DeleteBucketLifeCycleArgs.builder().bucket("my-bucketName").build());
Expand Down
15 changes: 9 additions & 6 deletions examples/DeleteBucketNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

minioClient.deleteBucketNotification(
DeleteBucketNotificationArgs.builder().bucket("my-bucketname").build());
Expand Down
15 changes: 9 additions & 6 deletions examples/DeleteBucketPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

minioClient.deleteBucketPolicy(
DeleteBucketPolicyArgs.builder().bucket("my-bucketname").build());
Expand Down
15 changes: 13 additions & 2 deletions examples/DeleteBucketTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ public class DeleteBucketTags {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
/* Amazon S3: */
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

minioClient.deleteBucketTags(DeleteBucketTagsArgs.builder().bucket("my-bucketname").build());
System.out.println("Bucket tags deleted successfully");
} catch (MinioException e) {
Expand Down
16 changes: 13 additions & 3 deletions examples/DeleteDefaultRetention.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ public class DeleteDefaultRetention {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
/* play.min.io for test and development. */
MinioClient minioClient =
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
MinioClient s3Client =
new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

s3Client.deleteDefaultRetention(
minioClient.deleteDefaultRetention(
DeleteDefaultRetentionArgs.builder().bucket("my-lock-enabled-bucketname").build());

System.out.println("Default retention configuration is deleted successfully");
Expand Down
15 changes: 13 additions & 2 deletions examples/DeleteObjectTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ public class DeleteObjectTags {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException {
try {
/* Amazon S3: */
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

minioClient.deleteObjectTags(
DeleteObjectTagsArgs.builder().bucket("my-bucketname").object("my-objectname").build());
System.out.println("Object tags deleted successfully");
Expand Down
16 changes: 11 additions & 5 deletions examples/DisableObjectLegalHold.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ public class DisableObjectLegalHold {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException, IllegalArgumentException {
try {

/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Disable object legal hold.
minioClient.disableObjectLegalHold(
Expand Down
15 changes: 9 additions & 6 deletions examples/DisableVersioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Disable versioning on 'my-bucketname'.
minioClient.disableVersioning(
Expand Down
15 changes: 9 additions & 6 deletions examples/DownloadObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

{
// Download 'my-objectname' from 'my-bucketname' to 'my-filename'
Expand Down
16 changes: 11 additions & 5 deletions examples/EnableObjectLegalHold.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ public class EnableObjectLegalHold {
public static void main(String[] args)
throws IOException, NoSuchAlgorithmException, InvalidKeyException, IllegalArgumentException {
try {

/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Enable object legal hold.
minioClient.enableObjectLegalHold(
Expand Down
15 changes: 9 additions & 6 deletions examples/EnableVersioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ public static void main(String[] args)
try {
/* play.min.io for test and development. */
MinioClient minioClient =
new MinioClient(
"https://play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();

/* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
// MinioClient minioClient =
// MinioClient.builder()
// .endpoint("https://s3.amazonaws.com")
// .credentials("YOUR-ACCESSKEY", "YOUR-SECRETACCESSKEY")
// .build();

// Enable versioning on 'my-bucketname'.
minioClient.enableVersioning(EnableVersioningArgs.builder().bucket("my-bucketname").build());
Expand Down
Loading