-
Notifications
You must be signed in to change notification settings - Fork 487
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
Make bucket with builder #927
Conversation
73eeb8e
to
199fb44
Compare
199fb44
to
7f85037
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended syntax for building the make-bucket args:
MakeBucketArgs.builder()
.bucket("<bucketname>")
.region("<region>")
.objectLock(<true/false>)
.build()
private String region; | ||
|
||
BucketArgs(Builder<?> builder) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this whitespace.
public String name; | ||
public String region; | ||
|
||
@SuppressWarnings("unchecked") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add justification as Its safe to type cast to T as T is inherited this class
.
this(new Builder()); | ||
} | ||
|
||
public Builder builder() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its been decided to add this feature later on demand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can find @anjalshireesh comment above, and thus i have made this as static and created the object like
MakeBucketArgs.builder()
.bucket("<bucketname>")
.region("<region>")
.objectLock(<true/false>)
.build()
@@ -1957,27 +1957,27 @@ public void getObject( | |||
* Creates an object by server-side copying data from another object. | |||
* | |||
* <pre>Example:{@code | |||
* // Copy data from my-source-bucketname/my-objectname to my-bucketname/my-objectname. | |||
* Copy data from my-source-bucketname/my-objectname to my-bucketname/my-objectname. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is code block. It should be a comment. Also touch relevant code to this PR.
docs/API.md
Outdated
|
||
__Example__ | ||
```java | ||
minioClient.makeBucket("my-bucketname", "us-west-2", true); | ||
// Create bucket with default region. | ||
minioClient.makeBucket(new MakeBucketArgs.Builder().bucket("my-bucketname").build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its better to have new line after each example.
docs/API.md
Outdated
minioClient.makeBucket(new MakeBucketArgs.Builder().bucket("my-bucketname").build()); | ||
// Create bucket with specific region. | ||
minioClient.makeBucket( | ||
new MakeBucketArgs.Builder().bucket("my-bucketname").region("us-west-1").build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make same indention like below example.
| ``objectLock`` | _boolean_ | Flag to enable object lock feature. | | ||
| Parameter | Type | Description | | ||
|:---------------|:-----------------|:---------------------------| | ||
| ``args`` | _[MakeBucketArgs]_ | Arguments to create bucket | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to add link to [MakeBucketArgs]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have tried the below but the link is visible. Is this correct approach
__Parameters__
| Parameter | Type | Description |
|:---------------|:-------------------|:---------------------------|
| ``args`` | _[MakeBucketArgs](#https://minio.github.io/minio-java/io/minio/MakeBucketArgs.html)_ | Arguments to create bucket |
examples/MakeBucketWithLock.java
Outdated
@@ -36,7 +37,8 @@ public static void main(String[] args) | |||
System.out.println("my-bucketname already exists"); | |||
} else { | |||
// Create bucket 'my-bucketname' with object lock functionality enabled | |||
s3Client.makeBucket("my-bucketname", null, true); | |||
s3Client.makeBucket( | |||
new MakeBucketArgs.Builder().bucket("my-bucketname").objectLock(true).build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you could have one example MakeBucket.java
and add three variation there.
functional/FunctionalTest.java
Outdated
public static void makeBucketwithRegion_test() throws Exception { | ||
if (!mintEnv) { | ||
System.out.println("Test: makeBucket(String bucketName, String region)"); | ||
System.out.println("Test: makeBucket(MakeBucketArgs args)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a tag like with region
, with objectLock
or with region and objectLock
@@ -16,30 +16,55 @@ | |||
|
|||
package io.minio; | |||
|
|||
/** Bucket Arguments to hold base bucket properties */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Base argument class holds bucket name and region */
this.region = builder.region; | ||
} | ||
|
||
/** Returns the name of bucket */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Returns bucket name */
to consistent with other docs.
return name; | ||
} | ||
|
||
/** Returns the region of bucket */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Returns region */
} | ||
|
||
@SuppressWarnings("unchecked") | ||
/** Its safe to type cast to T as T is inherited this class. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check how to add justification in @suppressWarnings
} | ||
|
||
/** Validate the name of the bucket */ | ||
public void validateName(String name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this as static
method.
|
||
public Builder() {} | ||
|
||
public Builder(MakeBucketArgs args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could remove Builder(XXXArgs args)
constructor everywhere and will be added on demand.
docs/API.md
Outdated
| ``region`` | _String_ | Region in which the bucket will be created. | | ||
| Parameter | Type | Description | | ||
|:---------------|:-------------------|:---------------------------| | ||
| ``args`` | _[MakeBucketArgs](#https://minio.github.io/minio-java/io/minio/MakeBucketArgs.html)_ | Arguments to create bucket | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check how [Method]
link is added as reference.
examples/MakeBucket.java
Outdated
.region("us-west-1") | ||
.objectLock(true) | ||
.build()); | ||
System.out.println("my-bucketname3 is created successfully"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You could have bucket names as
my-bucketname
,my-bucketname-in-eu
,my-bucketname-in-eu-with-object-lock
- I prefer longer block in
if
i.e.if (!minioClient.bucketExists(...)) {
is better.
functional/FunctionalTest.java
Outdated
public static void makeBucketwithRegion_test() throws Exception { | ||
if (!mintEnv) { | ||
System.out.println("Test: makeBucket(String bucketName, String region)"); | ||
System.out.println("Test: makeBucket(MakeBucketArgs args) with region"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tag before the API Test: with region: makeBucket(...)
functional/FunctionalTest.java
Outdated
@@ -303,6 +301,33 @@ public static void makeBucketWithPeriod_test() throws Exception { | |||
} | |||
} | |||
|
|||
/** Test: makeBucket(MakeBucketArgs args). */ | |||
public static void makeBucketwithRegioAndObjectLock() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use makeBucket_testN()
like other tests.
bbf54c3
to
076b9e7
Compare
076b9e7
to
0542e61
Compare
962b995
to
92caa86
Compare
build.gradle
Outdated
@@ -67,6 +67,7 @@ subprojects { | |||
it.options.fork = true | |||
it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"] | |||
it.options.encoding = "UTF-8" | |||
it.options.compilerArgs << "-Werror" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add "-Werror"
in it.options.compilerArgs +=
line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked
it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options", "-Werror"]
f60bb06
to
4af1da9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
No description provided.