Skip to content

Commit 303f836

Browse files
authored
Revert "[Storage] Bucket lock (#3574)"
This reverts commit 9f1a96b.
1 parent 9f1a96b commit 303f836

File tree

16 files changed

+22
-579
lines changed

16 files changed

+22
-579
lines changed

google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java

-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
* <li>createBatch
6666
* <li>checksums, etags
6767
* <li>IAM operations</li>
68-
* <li>BucketLock operations</li>
6968
* </ul>
7069
* </ul>
7170
*/
@@ -521,11 +520,6 @@ public Notification createNotification(String bucket, Notification notification)
521520
throw new UnsupportedOperationException();
522521
}
523522

524-
@Override
525-
public Bucket lockRetentionPolicy(Bucket bucket, Map<Option, ?> options) {
526-
throw new UnsupportedOperationException();
527-
}
528-
529523
@Override
530524
public ServiceAccount getServiceAccount(String projectId) {
531525
return null;

google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java

+1-18
Original file line numberDiff line numberDiff line change
@@ -402,30 +402,13 @@ Builder setCustomerEncryption(CustomerEncryption customerEncryption) {
402402
return this;
403403
}
404404

405+
@GcpLaunchStage.Beta
405406
@Override
406407
Builder setKmsKeyName(String kmsKeyName) {
407408
infoBuilder.setKmsKeyName(kmsKeyName);
408409
return this;
409410
}
410411

411-
@Override
412-
public Builder setEventBasedHold(Boolean eventBasedHold) {
413-
infoBuilder.setEventBasedHold(eventBasedHold);
414-
return this;
415-
}
416-
417-
@Override
418-
public Builder setTemporaryHold(Boolean temporaryHold) {
419-
infoBuilder.setTemporaryHold(temporaryHold);
420-
return this;
421-
}
422-
423-
@Override
424-
Builder setRetentionExpirationTime(Long retentionExpirationTime) {
425-
infoBuilder.setRetentionExpirationTime(retentionExpirationTime);
426-
return this;
427-
}
428-
429412
@Override
430413
public Blob build() {
431414
return new Blob(storage, infoBuilder);

google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobInfo.java

+6-76
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ 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;
9188

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

272269
abstract Builder setCustomerEncryption(CustomerEncryption customerEncryption);
273270

274-
abstract Builder setKmsKeyName(String kmsKeyName);
275-
276-
/**
277-
* Sets the blob's event based hold.
278-
*/
279-
public abstract Builder setEventBasedHold(Boolean eventBasedHold);
280-
281271
/**
282-
* Sets the blob's temporary hold.
272+
*
273+
* Sets the blob's kmsKeyName.
283274
*/
284-
public abstract Builder setTemporaryHold(Boolean temporaryHold);
285-
286-
abstract Builder setRetentionExpirationTime(Long retentionExpirationTime);
275+
@GcpLaunchStage.Beta
276+
abstract Builder setKmsKeyName(String kmsKeyName);
287277

288278
/**
289279
* Creates a {@code BlobInfo} object.
@@ -318,9 +308,6 @@ static final class BuilderImpl extends Builder {
318308
private CustomerEncryption customerEncryption;
319309
private StorageClass storageClass;
320310
private String kmsKeyName;
321-
private Boolean eventBasedHold;
322-
private Boolean temporaryHold;
323-
private Long retentionExpirationTime;
324311

325312
BuilderImpl(BlobId blobId) {
326313
this.blobId = blobId;
@@ -352,9 +339,6 @@ static final class BuilderImpl extends Builder {
352339
isDirectory = blobInfo.isDirectory;
353340
storageClass = blobInfo.storageClass;
354341
kmsKeyName = blobInfo.kmsKeyName;
355-
eventBasedHold = blobInfo.eventBasedHold;
356-
temporaryHold = blobInfo.temporaryHold;
357-
retentionExpirationTime = blobInfo.retentionExpirationTime;
358342
}
359343

360344
@Override
@@ -502,30 +486,13 @@ Builder setCustomerEncryption(CustomerEncryption customerEncryption) {
502486
return this;
503487
}
504488

489+
@GcpLaunchStage.Beta
505490
@Override
506491
Builder setKmsKeyName(String kmsKeyName) {
507492
this.kmsKeyName = kmsKeyName;
508493
return this;
509494
}
510495

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-
529496
@Override
530497
public BlobInfo build() {
531498
checkNotNull(blobId);
@@ -559,9 +526,6 @@ public BlobInfo build() {
559526
isDirectory = firstNonNull(builder.isDirectory, Boolean.FALSE);
560527
storageClass = builder.storageClass;
561528
kmsKeyName = builder.kmsKeyName;
562-
eventBasedHold = builder.eventBasedHold;
563-
temporaryHold = builder.temporaryHold;
564-
retentionExpirationTime = builder.retentionExpirationTime;
565529
}
566530

567531
/**
@@ -795,31 +759,11 @@ public StorageClass getStorageClass() {
795759
/**
796760
* Returns the Cloud KMS key used to encrypt the blob, if any.
797761
*/
762+
@GcpLaunchStage.Beta
798763
public String getKmsKeyName() {
799764
return kmsKeyName;
800765
}
801766

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-
823767
/**
824768
* Returns a builder for the current blob.
825769
*/
@@ -892,13 +836,8 @@ public ObjectAccessControl apply(Acl acl) {
892836
if (customerEncryption != null) {
893837
storageObject.setCustomerEncryption(customerEncryption.toPb());
894838
}
895-
if (retentionExpirationTime != null) {
896-
storageObject.setRetentionExpirationTime(new DateTime(retentionExpirationTime));
897-
}
898839

899840
storageObject.setKmsKeyName(kmsKeyName);
900-
storageObject.setEventBasedHold(eventBasedHold);
901-
storageObject.setTemporaryHold(temporaryHold);
902841
storageObject.setMetadata(pbMetadata);
903842
storageObject.setCacheControl(cacheControl);
904843
storageObject.setContentEncoding(contentEncoding);
@@ -1032,15 +971,6 @@ public Acl apply(ObjectAccessControl objectAccessControl) {
1032971
if (storageObject.getKmsKeyName() != null) {
1033972
builder.setKmsKeyName(storageObject.getKmsKeyName());
1034973
}
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-
}
1044974
return builder.build();
1045975
}
1046976
}

google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java

+1-47
Original file line numberDiff line numberDiff line change
@@ -628,36 +628,13 @@ public Builder setLabels(Map<String, String> labels) {
628628
return this;
629629
}
630630

631+
@GcpLaunchStage.Beta
631632
@Override
632633
public Builder setDefaultKmsKeyName(String defaultKmsKeyName) {
633634
infoBuilder.setDefaultKmsKeyName(defaultKmsKeyName);
634635
return this;
635636
}
636637

637-
@Override
638-
public Builder setDefaultEventBasedHold(Boolean defaultEventBasedHold) {
639-
infoBuilder.setDefaultEventBasedHold(defaultEventBasedHold);
640-
return this;
641-
}
642-
643-
@Override
644-
Builder setRetentionEffectiveTime(Long retentionEffectiveTime) {
645-
infoBuilder.setRetentionEffectiveTime(retentionEffectiveTime);
646-
return this;
647-
}
648-
649-
@Override
650-
Builder setRetentionPolicyIsLocked(Boolean retentionIsLocked) {
651-
infoBuilder.setRetentionPolicyIsLocked(retentionIsLocked);
652-
return this;
653-
}
654-
655-
@Override
656-
public Builder setRetentionPeriod(Long retentionPeriod) {
657-
infoBuilder.setRetentionPeriod(retentionPeriod);
658-
return this;
659-
}
660-
661638
@Override
662639
public Bucket build() {
663640
return new Bucket(storage, infoBuilder);
@@ -1134,29 +1111,6 @@ public List<Acl> listDefaultAcls() {
11341111
return storage.listDefaultAcls(getName());
11351112
}
11361113

1137-
/**
1138-
* Locks bucket retention policy. Requires a local metageneration value in the request. Review example below.
1139-
*
1140-
* <p>Accepts an optional userProject {@link BucketTargetOption} option which defines the project id
1141-
* to assign operational costs.
1142-
*
1143-
* <p>Warning: Once a retention policy is locked, it can't be unlocked, removed, or shortened.
1144-
*
1145-
* <p>Example of locking a retention policy on a bucket, only if its local metageneration value matches the bucket's
1146-
* service metageneration otherwise a {@link StorageException} is thrown.
1147-
* <pre> {@code
1148-
* String bucketName = "my_unique_bucket";
1149-
* Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.METAGENERATION));
1150-
* storage.lockRetentionPolicy(bucket, BucketTargetOption.metagenerationMatch());
1151-
* }</pre>
1152-
*
1153-
* @return a {@code Bucket} object of the locked bucket
1154-
* @throws StorageException upon failure
1155-
*/
1156-
public Bucket lockRetentionPolicy(BucketTargetOption... options) {
1157-
return storage.lockRetentionPolicy(this, options);
1158-
}
1159-
11601114
/**
11611115
* Returns the bucket's {@code Storage} object used to issue requests.
11621116
*/

0 commit comments

Comments
 (0)