Skip to content

Commit

Permalink
add {set,get}BucketVersioning APIs
Browse files Browse the repository at this point in the history
Fixes #1050
  • Loading branch information
balamurugana committed Sep 15, 2020
1 parent dfb7658 commit 468e9d6
Show file tree
Hide file tree
Showing 12 changed files with 8,527 additions and 398 deletions.
27 changes: 0 additions & 27 deletions api/src/main/java/io/minio/EnableVersioningArgs.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

package io.minio;

/** Argument class of MinioClient.disableVersioning(). */
public class DisableVersioningArgs extends BucketArgs {
/** Argument class of MinioClient.getBucketVersioning(). */
public class GetBucketVersioningArgs extends BucketArgs {
public static Builder builder() {
return new Builder();
}

/** Argument builder of {@link DisableVersioningArgs}. */
public static final class Builder extends BucketArgs.Builder<Builder, DisableVersioningArgs> {}
/** Argument builder of {@link GetBucketVersioningArgs}. */
public static final class Builder extends BucketArgs.Builder<Builder, GetBucketVersioningArgs> {}
}
27 changes: 0 additions & 27 deletions api/src/main/java/io/minio/IsVersioningEnabledArgs.java

This file was deleted.

127 changes: 14 additions & 113 deletions api/src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3984,13 +3984,14 @@ public void makeBucket(MakeBucketArgs args)
}

/**
* Enables object versioning feature in a bucket.
* Sets versioning configuration of a bucket.
*
* <pre>Example:{@code
* minioClient.enableVersioning("my-bucketname");
* minioClient.setBucketVersioning(
* SetBucketVersioningArgs.builder().bucket("my-bucketname").config(config).build());
* }</pre>
*
* @param bucketName Name of the bucket.
* @param args {@link SetBucketVersioningArgs} object.
* @throws ErrorResponseException thrown to indicate S3 service returned an error response.
* @throws IllegalArgumentException throws to indicate invalid argument passed.
* @throws InsufficientDataException thrown to indicate not enough data available in InputStream.
Expand All @@ -4002,56 +4003,28 @@ public void makeBucket(MakeBucketArgs args)
* @throws IOException thrown to indicate I/O error on S3 operation.
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
* @throws XmlParserException thrown to indicate XML parsing error.
* @deprecated use {@link #enableVersioning(EnableVersioningArgs)}
*/
@Deprecated
public void enableVersioning(String bucketName)
throws ErrorResponseException, IllegalArgumentException, InsufficientDataException,
InternalException, InvalidBucketNameException, InvalidKeyException,
InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException,
XmlParserException {
this.enableVersioning(EnableVersioningArgs.builder().bucket(bucketName).build());
}

/**
* Enables object versioning feature in a bucket.
*
* <pre>Example:{@code
* minioClient.enableVersioning(EnableVersioningArgs.builder().bucket("my-bucketname").build());
* }</pre>
*
* @param args {@link EnableVersioningArgs} object.
* @throws ErrorResponseException thrown to indicate S3 service returned an error response.
* @throws IllegalArgumentException throws to indicate invalid argument passed.
* @throws InsufficientDataException thrown to indicate not enough data available in InputStream.
* @throws InternalException thrown to indicate internal library error.
* @throws InvalidBucketNameException thrown to indicate invalid bucket name passed.
* @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library.
* @throws InvalidResponseException thrown to indicate S3 service returned invalid or no error
* response.
* @throws IOException thrown to indicate I/O error on S3 operation.
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
* @throws XmlParserException thrown to indicate XML parsing error.
*/
public void enableVersioning(EnableVersioningArgs args)
public void setBucketVersioning(SetBucketVersioningArgs args)
throws ErrorResponseException, IllegalArgumentException, InsufficientDataException,
InternalException, InvalidBucketNameException, InvalidKeyException,
InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException,
XmlParserException {
checkArgs(args);
Response response =
executePut(args, null, newMultimap("versioning", ""), new VersioningConfiguration(true), 0);
Response response = executePut(args, null, newMultimap("versioning", ""), args.config(), 0);
response.close();
}

/**
* Disables object versioning feature in a bucket.
* Gets versioning configuration of a bucket.
*
* <pre>Example:{@code
* minioClient.disableVersioning("my-bucketname");
* VersioningConfiguration config =
* minioClient.getBucketVersioning(
* GetBucketVersioningArgs.builder().bucket("my-bucketname").build());
* }</pre>
*
* @param bucketName Name of the bucket.
* @param args {@link GetBucketVersioningArgs} object.
* @return {@link VersioningConfiguration} - Versioning configuration.
* @throws ErrorResponseException thrown to indicate S3 service returned an error response.
* @throws IllegalArgumentException throws to indicate invalid argument passed.
* @throws InsufficientDataException thrown to indicate not enough data available in InputStream.
Expand All @@ -4063,87 +4036,15 @@ public void enableVersioning(EnableVersioningArgs args)
* @throws IOException thrown to indicate I/O error on S3 operation.
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
* @throws XmlParserException thrown to indicate XML parsing error.
* @deprecated use {@link #disableVersioning(DisableVersioningArgs)}
*/
@Deprecated
public void disableVersioning(String bucketName)
throws ErrorResponseException, IllegalArgumentException, InsufficientDataException,
InternalException, InvalidBucketNameException, InvalidKeyException,
InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException,
XmlParserException {
this.disableVersioning(DisableVersioningArgs.builder().bucket(bucketName).build());
}

/**
* Disables object versioning feature in a bucket.
*
* <pre>Example:{@code
* minioClient.disableVersioning(
* DisableVersioningArgs.builder().bucket("my-bucketname").build());
* }</pre>
*
* @param args {@link DisableVersioningArgs} object.
* @throws ErrorResponseException thrown to indicate S3 service returned an error response.
* @throws IllegalArgumentException throws to indicate invalid argument passed.
* @throws InsufficientDataException thrown to indicate not enough data available in InputStream.
* @throws InternalException thrown to indicate internal library error.
* @throws InvalidBucketNameException thrown to indicate invalid bucket name passed.
* @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library.
* @throws InvalidResponseException thrown to indicate S3 service returned invalid or no error
* response.
* @throws IOException thrown to indicate I/O error on S3 operation.
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
* @throws XmlParserException thrown to indicate XML parsing error.
*/
public void disableVersioning(DisableVersioningArgs args)
throws ErrorResponseException, IllegalArgumentException, InsufficientDataException,
InternalException, InvalidBucketNameException, InvalidKeyException,
InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException,
XmlParserException {
checkArgs(args);
Response response =
executePut(
args, null, newMultimap("versioning", ""), new VersioningConfiguration(false), 0);
response.close();
}

/**
* Returns true if versioning is enabled on the bucket.
*
* <pre>Example:{@code
* boolean isVersioningEnabled =
* minioClient.isVersioningEnabled(
* IsVersioningEnabledArgs.builder().bucket("my-bucketname").build());
* if (isVersioningEnabled) {
* System.out.println("Bucket versioning is enabled");
* } else {
* System.out.println("Bucket versioning is disabled");
* }
* }</pre>
*
* @param args {@link IsVersioningEnabledArgs} object.
* @throws ErrorResponseException thrown to indicate S3 service returned an error response.
* @throws IllegalArgumentException throws to indicate invalid argument passed.
* @throws InsufficientDataException thrown to indicate not enough data available in InputStream.
* @throws InternalException thrown to indicate internal library error.
* @throws InvalidBucketNameException thrown to indicate invalid bucket name passed.
* @throws InvalidKeyException thrown to indicate missing of HMAC SHA-256 library.
* @throws InvalidResponseException thrown to indicate S3 service returned invalid or no error
* response.
* @throws IOException thrown to indicate I/O error on S3 operation.
* @throws NoSuchAlgorithmException thrown to indicate missing of MD5 or SHA-256 digest library.
* @throws XmlParserException thrown to indicate XML parsing error.
*/
public boolean isVersioningEnabled(IsVersioningEnabledArgs args)
public VersioningConfiguration getBucketVersioning(GetBucketVersioningArgs args)
throws ErrorResponseException, IllegalArgumentException, InsufficientDataException,
InternalException, InvalidBucketNameException, InvalidKeyException,
InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException,
XmlParserException {
checkArgs(args);
try (Response response = executeGet(args, null, newMultimap("versioning", ""))) {
VersioningConfiguration result =
Xml.unmarshal(VersioningConfiguration.class, response.body().charStream());
return result.status();
return Xml.unmarshal(VersioningConfiguration.class, response.body().charStream());
}
}

Expand Down
Loading

0 comments on commit 468e9d6

Please sign in to comment.