[Storage] Bucket lock by frankyn · Pull Request #3574 · googleapis/google-cloud-java · GitHub
Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,30 @@ Builder setCustomerEncryption(CustomerEncryption customerEncryption) {
return this;
}

@GcpLaunchStage.Beta
@Override
Builder setKmsKeyName(String kmsKeyName) {
infoBuilder.setKmsKeyName(kmsKeyName);
return this;
}

@Override
public Builder setEventBasedHold(Boolean eventBasedHold) {
infoBuilder.setEventBasedHold(eventBasedHold);
return this;
}

@Override
public Builder setTemporaryHold(Boolean temporaryHold) {
infoBuilder.setTemporaryHold(temporaryHold);
return this;
}

@Override
Builder setRetentionExpirationTime(Long retentionExpirationTime) {
infoBuilder.setRetentionExpirationTime(retentionExpirationTime);
return this;
}

@Override
public Blob build() {
return new Blob(storage, infoBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public StorageObject apply(BlobInfo blobInfo) {
private final boolean isDirectory;
private final CustomerEncryption customerEncryption;
private final String kmsKeyName;
private final Boolean eventBasedHold;
private final Boolean temporaryHold;
private final Long retentionExpirationTime;

/**
* This class is meant for internal use only. Users are discouraged from using this class.
Expand Down Expand Up @@ -268,12 +271,19 @@ public abstract static class Builder {

abstract Builder setCustomerEncryption(CustomerEncryption customerEncryption);

abstract Builder setKmsKeyName(String kmsKeyName);

/**
*
* Sets the blob's kmsKeyName.
* Sets the blob's event based hold.
*/
@GcpLaunchStage.Beta
abstract Builder setKmsKeyName(String kmsKeyName);
public abstract Builder setEventBasedHold(Boolean eventBasedHold);

/**
* Sets the blob's temporary hold.
*/
public abstract Builder setTemporaryHold(Boolean temporaryHold);

abstract Builder setRetentionExpirationTime(Long retentionExpirationTime);

/**
* Creates a {@code BlobInfo} object.
Expand Down Expand Up @@ -308,6 +318,9 @@ static final class BuilderImpl extends Builder {
private CustomerEncryption customerEncryption;
private StorageClass storageClass;
private String kmsKeyName;
private Boolean eventBasedHold;
private Boolean temporaryHold;
private Long retentionExpirationTime;

BuilderImpl(BlobId blobId) {
this.blobId = blobId;
Expand Down Expand Up @@ -339,6 +352,9 @@ static final class BuilderImpl extends Builder {
isDirectory = blobInfo.isDirectory;
storageClass = blobInfo.storageClass;
kmsKeyName = blobInfo.kmsKeyName;
eventBasedHold = blobInfo.eventBasedHold;
temporaryHold = blobInfo.temporaryHold;
retentionExpirationTime = blobInfo.retentionExpirationTime;
}

@Override
Expand Down Expand Up @@ -486,13 +502,30 @@ Builder setCustomerEncryption(CustomerEncryption customerEncryption) {
return this;
}

@GcpLaunchStage.Beta
@Override
Builder setKmsKeyName(String kmsKeyName) {
this.kmsKeyName = kmsKeyName;
return this;
}

@Override
public Builder setEventBasedHold(Boolean eventBasedHold) {
this.eventBasedHold = eventBasedHold;
return this;
}

@Override
public Builder setTemporaryHold(Boolean temporaryHold) {
this.temporaryHold = temporaryHold;
return this;
}

@Override
Builder setRetentionExpirationTime(Long retentionExpirationTime) {
this.retentionExpirationTime = retentionExpirationTime;
return this;
}

@Override
public BlobInfo build() {
checkNotNull(blobId);
Expand Down Expand Up @@ -526,6 +559,9 @@ public BlobInfo build() {
isDirectory = firstNonNull(builder.isDirectory, Boolean.FALSE);
storageClass = builder.storageClass;
kmsKeyName = builder.kmsKeyName;
eventBasedHold = builder.eventBasedHold;
temporaryHold = builder.temporaryHold;
retentionExpirationTime = builder.retentionExpirationTime;
}

/**
Expand Down Expand Up @@ -759,11 +795,31 @@ public StorageClass getStorageClass() {
/**
* Returns the Cloud KMS key used to encrypt the blob, if any.
*/
@GcpLaunchStage.Beta
public String getKmsKeyName() {
return kmsKeyName;
}

/**
* Returns the event based hold status of the blob, if any.
*/
public Boolean getEventBasedHold() {
return eventBasedHold;
}

/**
* Returns the temporary hold status of the blob, if any.
*/
public Boolean getTemporaryHold() {
return temporaryHold;
}

/**
* Returns the retention expiration time of the blob, if a retention period is defined.
*/
public Long getRetentionExpirationTime() {
return retentionExpirationTime;
}

/**
* Returns a builder for the current blob.
*/
Expand Down Expand Up @@ -836,8 +892,13 @@ public ObjectAccessControl apply(Acl acl) {
if (customerEncryption != null) {
storageObject.setCustomerEncryption(customerEncryption.toPb());
}
if (retentionExpirationTime != null) {
storageObject.setRetentionExpirationTime(new DateTime(retentionExpirationTime));
}

storageObject.setKmsKeyName(kmsKeyName);
storageObject.setEventBasedHold(eventBasedHold);
storageObject.setTemporaryHold(temporaryHold);
storageObject.setMetadata(pbMetadata);
storageObject.setCacheControl(cacheControl);
storageObject.setContentEncoding(contentEncoding);
Expand Down Expand Up @@ -971,6 +1032,15 @@ public Acl apply(ObjectAccessControl objectAccessControl) {
if (storageObject.getKmsKeyName() != null) {
builder.setKmsKeyName(storageObject.getKmsKeyName());
}
if (storageObject.getEventBasedHold() != null) {
builder.setEventBasedHold(storageObject.getEventBasedHold());
}
if (storageObject.getTemporaryHold() != null) {
builder.setTemporaryHold(storageObject.getTemporaryHold());
}
if (storageObject.getRetentionExpirationTime() != null) {
builder.setRetentionExpirationTime(storageObject.getRetentionExpirationTime().getValue());
}
return builder.build();
}
}
Loading