@@ -44,6 +44,11 @@ public final class OmBucketArgs extends WithMetadata implements Auditable {
4444 * Bucket Version flag.
4545 */
4646 private final Boolean isVersionEnabled ;
47+ /**
48+ * S3-compatible versioning status; null when not being changed.
49+ * Takes precedence over isVersionEnabled when both are set.
50+ */
51+ private final BucketVersioningStatus versioningStatus ;
4752 /**
4853 * Type of storage to be used for this bucket.
4954 * [RAM_DISK, SSD, DISK, ARCHIVE]
@@ -73,6 +78,7 @@ private OmBucketArgs(Builder b) {
7378 this .volumeName = b .volumeName ;
7479 this .bucketName = b .bucketName ;
7580 this .isVersionEnabled = b .isVersionEnabled ;
81+ this .versioningStatus = b .versioningStatus ;
7682 this .storageType = b .storageType ;
7783 this .ownerName = b .ownerName ;
7884 this .defaultReplicationConfig = b .defaultReplicationConfig ;
@@ -108,6 +114,14 @@ public Boolean getIsVersionEnabled() {
108114 return isVersionEnabled ;
109115 }
110116
117+ /**
118+ * Returns the requested versioning status, or null if not being changed.
119+ * @return BucketVersioningStatus
120+ */
121+ public BucketVersioningStatus getVersioningStatus () {
122+ return versioningStatus ;
123+ }
124+
111125 /**
112126 * Returns the type of storage to be used.
113127 * @return StorageType
@@ -190,6 +204,9 @@ public Map<String, String> toAuditMap() {
190204 getMetadata ().get (OzoneConsts .GDPR_FLAG ));
191205 auditMap .put (OzoneConsts .IS_VERSION_ENABLED ,
192206 String .valueOf (this .isVersionEnabled ));
207+ if (this .versioningStatus != null ) {
208+ auditMap .put (OzoneConsts .VERSIONING_STATUS , this .versioningStatus .name ());
209+ }
193210 if (this .storageType != null ) {
194211 auditMap .put (OzoneConsts .STORAGE_TYPE , this .storageType .name ());
195212 }
@@ -227,6 +244,7 @@ public static class Builder extends WithMetadata.Builder {
227244 private String volumeName ;
228245 private String bucketName ;
229246 private Boolean isVersionEnabled ;
247+ private BucketVersioningStatus versioningStatus ;
230248 private StorageType storageType ;
231249 private boolean quotaInBytesSet = false ;
232250 private long quotaInBytes ;
@@ -261,6 +279,11 @@ public Builder setIsVersionEnabled(Boolean versionFlag) {
261279 return this ;
262280 }
263281
282+ public Builder setVersioningStatus (BucketVersioningStatus status ) {
283+ this .versioningStatus = status ;
284+ return this ;
285+ }
286+
264287 @ Deprecated
265288 public Builder setBucketEncryptionKey (BucketEncryptionKeyInfo info ) {
266289 if (info == null || info .getKeyName () != null ) {
@@ -339,6 +362,9 @@ public BucketArgs getProtobuf() {
339362 if (isVersionEnabled != null ) {
340363 builder .setIsVersionEnabled (isVersionEnabled );
341364 }
365+ if (versioningStatus != null ) {
366+ builder .setVersioningStatus (versioningStatus .toProto ());
367+ }
342368 if (storageType != null ) {
343369 builder .setStorageType (storageType .toProto ());
344370 }
@@ -381,6 +407,10 @@ public static Builder builderFromProtobuf(BucketArgs bucketArgs) {
381407 if (bucketArgs .hasIsVersionEnabled ()) {
382408 builder .setIsVersionEnabled (bucketArgs .getIsVersionEnabled ());
383409 }
410+ if (bucketArgs .hasVersioningStatus ()) {
411+ builder .setVersioningStatus (
412+ BucketVersioningStatus .fromProto (bucketArgs .getVersioningStatus ()));
413+ }
384414 if (bucketArgs .hasStorageType ()) {
385415 builder .setStorageType (StorageType .valueOf (bucketArgs .getStorageType ()));
386416 }
0 commit comments