Skip to content

Commit

Permalink
Revert "[Storage] Bucket lock (googleapis#3574)" (googleapis#3644)
Browse files Browse the repository at this point in the history
This reverts commit 9f1a96b.
  • Loading branch information
frankyn authored and andreamlin committed Sep 5, 2018
1 parent 7f3ab97 commit 124ed55
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 579 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
* <li>createBatch
* <li>checksums, etags
* <li>IAM operations</li>
* <li>BucketLock operations</li>
* </ul>
* </ul>
*/
Expand Down Expand Up @@ -521,11 +520,6 @@ public Notification createNotification(String bucket, Notification notification)
throw new UnsupportedOperationException();
}

@Override
public Bucket lockRetentionPolicy(Bucket bucket, Map<Option, ?> options) {
throw new UnsupportedOperationException();
}

@Override
public ServiceAccount getServiceAccount(String projectId) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,30 +402,13 @@ 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,9 +85,6 @@ 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 @@ -271,19 +268,12 @@ public abstract static class Builder {

abstract Builder setCustomerEncryption(CustomerEncryption customerEncryption);

abstract Builder setKmsKeyName(String kmsKeyName);

/**
* Sets the blob's event based hold.
*/
public abstract Builder setEventBasedHold(Boolean eventBasedHold);

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

abstract Builder setRetentionExpirationTime(Long retentionExpirationTime);
@GcpLaunchStage.Beta
abstract Builder setKmsKeyName(String kmsKeyName);

/**
* Creates a {@code BlobInfo} object.
Expand Down Expand Up @@ -318,9 +308,6 @@ 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 @@ -352,9 +339,6 @@ 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 @@ -502,30 +486,13 @@ 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 @@ -559,9 +526,6 @@ 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 @@ -795,31 +759,11 @@ 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 @@ -892,13 +836,8 @@ 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 @@ -1032,15 +971,6 @@ 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -628,36 +628,13 @@ public Builder setLabels(Map<String, String> labels) {
return this;
}

@GcpLaunchStage.Beta
@Override
public Builder setDefaultKmsKeyName(String defaultKmsKeyName) {
infoBuilder.setDefaultKmsKeyName(defaultKmsKeyName);
return this;
}

@Override
public Builder setDefaultEventBasedHold(Boolean defaultEventBasedHold) {
infoBuilder.setDefaultEventBasedHold(defaultEventBasedHold);
return this;
}

@Override
Builder setRetentionEffectiveTime(Long retentionEffectiveTime) {
infoBuilder.setRetentionEffectiveTime(retentionEffectiveTime);
return this;
}

@Override
Builder setRetentionPolicyIsLocked(Boolean retentionIsLocked) {
infoBuilder.setRetentionPolicyIsLocked(retentionIsLocked);
return this;
}

@Override
public Builder setRetentionPeriod(Long retentionPeriod) {
infoBuilder.setRetentionPeriod(retentionPeriod);
return this;
}

@Override
public Bucket build() {
return new Bucket(storage, infoBuilder);
Expand Down Expand Up @@ -1134,29 +1111,6 @@ public List<Acl> listDefaultAcls() {
return storage.listDefaultAcls(getName());
}

/**
* Locks bucket retention policy. Requires a local metageneration value in the request. Review example below.
*
* <p>Accepts an optional userProject {@link BucketTargetOption} option which defines the project id
* to assign operational costs.
*
* <p>Warning: Once a retention policy is locked, it can't be unlocked, removed, or shortened.
*
* <p>Example of locking a retention policy on a bucket, only if its local metageneration value matches the bucket's
* service metageneration otherwise a {@link StorageException} is thrown.
* <pre> {@code
* String bucketName = "my_unique_bucket";
* Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.METAGENERATION));
* storage.lockRetentionPolicy(bucket, BucketTargetOption.metagenerationMatch());
* }</pre>
*
* @return a {@code Bucket} object of the locked bucket
* @throws StorageException upon failure
*/
public Bucket lockRetentionPolicy(BucketTargetOption... options) {
return storage.lockRetentionPolicy(this, options);
}

/**
* Returns the bucket's {@code Storage} object used to issue requests.
*/
Expand Down
Loading

0 comments on commit 124ed55

Please sign in to comment.