@@ -85,6 +85,9 @@ public StorageObject apply(BlobInfo blobInfo) {
8585 private final boolean isDirectory ;
8686 private final CustomerEncryption customerEncryption ;
8787 private final String kmsKeyName ;
88+ private final Boolean eventBasedHold ;
89+ private final Boolean temporaryHold ;
90+ private final Long retentionExpirationTime ;
8891
8992 /**
9093 * This class is meant for internal use only. Users are discouraged from using this class.
@@ -268,12 +271,19 @@ public abstract static class Builder {
268271
269272 abstract Builder setCustomerEncryption (CustomerEncryption customerEncryption );
270273
274+ abstract Builder setKmsKeyName (String kmsKeyName );
275+
271276 /**
272- *
273- * Sets the blob's kmsKeyName.
277+ * Sets the blob's event based hold.
274278 */
275- @ GcpLaunchStage .Beta
276- abstract Builder setKmsKeyName (String kmsKeyName );
279+ public abstract Builder setEventBasedHold (Boolean eventBasedHold );
280+
281+ /**
282+ * Sets the blob's temporary hold.
283+ */
284+ public abstract Builder setTemporaryHold (Boolean temporaryHold );
285+
286+ abstract Builder setRetentionExpirationTime (Long retentionExpirationTime );
277287
278288 /**
279289 * Creates a {@code BlobInfo} object.
@@ -308,6 +318,9 @@ static final class BuilderImpl extends Builder {
308318 private CustomerEncryption customerEncryption ;
309319 private StorageClass storageClass ;
310320 private String kmsKeyName ;
321+ private Boolean eventBasedHold ;
322+ private Boolean temporaryHold ;
323+ private Long retentionExpirationTime ;
311324
312325 BuilderImpl (BlobId blobId ) {
313326 this .blobId = blobId ;
@@ -339,6 +352,9 @@ static final class BuilderImpl extends Builder {
339352 isDirectory = blobInfo .isDirectory ;
340353 storageClass = blobInfo .storageClass ;
341354 kmsKeyName = blobInfo .kmsKeyName ;
355+ eventBasedHold = blobInfo .eventBasedHold ;
356+ temporaryHold = blobInfo .temporaryHold ;
357+ retentionExpirationTime = blobInfo .retentionExpirationTime ;
342358 }
343359
344360 @ Override
@@ -486,13 +502,30 @@ Builder setCustomerEncryption(CustomerEncryption customerEncryption) {
486502 return this ;
487503 }
488504
489- @ GcpLaunchStage .Beta
490505 @ Override
491506 Builder setKmsKeyName (String kmsKeyName ) {
492507 this .kmsKeyName = kmsKeyName ;
493508 return this ;
494509 }
495510
511+ @ Override
512+ public Builder setEventBasedHold (Boolean eventBasedHold ) {
513+ this .eventBasedHold = eventBasedHold ;
514+ return this ;
515+ }
516+
517+ @ Override
518+ public Builder setTemporaryHold (Boolean temporaryHold ) {
519+ this .temporaryHold = temporaryHold ;
520+ return this ;
521+ }
522+
523+ @ Override
524+ Builder setRetentionExpirationTime (Long retentionExpirationTime ) {
525+ this .retentionExpirationTime = retentionExpirationTime ;
526+ return this ;
527+ }
528+
496529 @ Override
497530 public BlobInfo build () {
498531 checkNotNull (blobId );
@@ -526,6 +559,9 @@ public BlobInfo build() {
526559 isDirectory = firstNonNull (builder .isDirectory , Boolean .FALSE );
527560 storageClass = builder .storageClass ;
528561 kmsKeyName = builder .kmsKeyName ;
562+ eventBasedHold = builder .eventBasedHold ;
563+ temporaryHold = builder .temporaryHold ;
564+ retentionExpirationTime = builder .retentionExpirationTime ;
529565 }
530566
531567 /**
@@ -759,11 +795,31 @@ public StorageClass getStorageClass() {
759795 /**
760796 * Returns the Cloud KMS key used to encrypt the blob, if any.
761797 */
762- @ GcpLaunchStage .Beta
763798 public String getKmsKeyName () {
764799 return kmsKeyName ;
765800 }
766801
802+ /**
803+ * Returns the event based hold status of the blob, if any.
804+ */
805+ public Boolean getEventBasedHold () {
806+ return eventBasedHold ;
807+ }
808+
809+ /**
810+ * Returns the temporary hold status of the blob, if any.
811+ */
812+ public Boolean getTemporaryHold () {
813+ return temporaryHold ;
814+ }
815+
816+ /**
817+ * Returns the retention expiration time of the blob, if a retention period is defined.
818+ */
819+ public Long getRetentionExpirationTime () {
820+ return retentionExpirationTime ;
821+ }
822+
767823 /**
768824 * Returns a builder for the current blob.
769825 */
@@ -836,8 +892,13 @@ public ObjectAccessControl apply(Acl acl) {
836892 if (customerEncryption != null ) {
837893 storageObject .setCustomerEncryption (customerEncryption .toPb ());
838894 }
895+ if (retentionExpirationTime != null ) {
896+ storageObject .setRetentionExpirationTime (new DateTime (retentionExpirationTime ));
897+ }
839898
840899 storageObject .setKmsKeyName (kmsKeyName );
900+ storageObject .setEventBasedHold (eventBasedHold );
901+ storageObject .setTemporaryHold (temporaryHold );
841902 storageObject .setMetadata (pbMetadata );
842903 storageObject .setCacheControl (cacheControl );
843904 storageObject .setContentEncoding (contentEncoding );
@@ -971,6 +1032,15 @@ public Acl apply(ObjectAccessControl objectAccessControl) {
9711032 if (storageObject .getKmsKeyName () != null ) {
9721033 builder .setKmsKeyName (storageObject .getKmsKeyName ());
9731034 }
1035+ if (storageObject .getEventBasedHold () != null ) {
1036+ builder .setEventBasedHold (storageObject .getEventBasedHold ());
1037+ }
1038+ if (storageObject .getTemporaryHold () != null ) {
1039+ builder .setTemporaryHold (storageObject .getTemporaryHold ());
1040+ }
1041+ if (storageObject .getRetentionExpirationTime () != null ) {
1042+ builder .setRetentionExpirationTime (storageObject .getRetentionExpirationTime ().getValue ());
1043+ }
9741044 return builder .build ();
9751045 }
9761046}
0 commit comments