Skip to content

[Storage] Bucket lock samples and bug fixes. - #3709

Merged
frankyn merged 4 commits into
gcs-bucket-lock-readyfrom
gcs-bucket-lock-samples
Sep 22, 2018
Merged

[Storage] Bucket lock samples and bug fixes.#3709
frankyn merged 4 commits into
gcs-bucket-lock-readyfrom
gcs-bucket-lock-samples

Conversation

@frankyn

@frankynfrankyn commented Sep 20, 2018

Copy link
Copy Markdown
Contributor

Bug fixes from sample review

  • Clean up comments for Boolean types in the Storage client library to explain possible states.
  • Fix Integration tests that kept failing due to objects with retention by releasing holds during cleanup.
  • Fix bug in client library not allowing to clear retentionPolicy correctly.
  • Be consistent with how Booleans are handled between Bucket and Blob classes.
  • Reformat BlobInfo and BucketInfo classes.

Samples

  • Update storage snippets bucket clean up to follow integration tests.
  • Define a retention policy
  • Remove a retention policy if not locked
  • Lock a retention policy
  • Set temporary hold
  • Release temporary hold
  • Set event-based hold
  • Release event-based hold
  • Set default event-based hold
  • Release default event-based hold
  • View default event-based hold
  • View bucket retention policy metadata
  • View metadata for object
  • Run formatter.

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 20, 2018
for (Blob blob : bucket.list(BlobListOption.fields(Storage.BlobField.EVENT_BASED_HOLD,
Storage.BlobField.TEMPORARY_HOLD)).iterateAll()) {
if(blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
BlobInfo.Builder blobBuilder = BlobInfo.newBuilder(bucket.getName(), blob.getName());

This comment was marked as spam.

This comment was marked as spam.

System.out.println("Last Metadata Update: " + new Date(blob.getUpdateTime()));
System.out.println(
"temporaryHold: "
+ (blob.getTemporaryHold() != null && blob.getTemporaryHold()

This comment was marked as spam.

This comment was marked as spam.

if (blob.getMetadata() != null) {
System.out.println("User metadata:");
for (Map.Entry<String, String> userMetadata : blob.getMetadata().entrySet()) {
System.out.println(userMetadata.getKey() + " " + userMetadata.getValue());

This comment was marked as spam.

This comment was marked as spam.

Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.RETENTION_POLICY));
if (bucket.retentionPolicyIsLocked() != null && bucket.retentionPolicyIsLocked()) {
System.out.println("Unable to remove retention period as retention policy is locked.");
return bucket;

This comment was marked as spam.

This comment was marked as spam.

return bucket;
}

Bucket updated_bucket = bucket.toBuilder().setRetentionPeriod(null).build().update();

This comment was marked as spam.

This comment was marked as spam.

Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.RETENTION_POLICY));

System.out.println("Retention Policy for " + bucketName);

This comment was marked as spam.

This comment was marked as spam.


Bucket bucket =
storage.get(bucketName, Storage.BucketGetOption.fields(BucketField.METAGENERATION));
Bucket updated_bucket =

This comment was marked as spam.

This comment was marked as spam.

Bucket bucket =
storage.get(bucketName, BucketGetOption.fields(BucketField.DEFAULT_EVENT_BASED_HOLD));

if (bucket.getDefaultEventBasedHold() == true) {

This comment was marked as spam.

This comment was marked as spam.

@frankyn

Copy link
Copy Markdown
ContributorAuthor

Comments addressed. @kurtisvg PTAL

@kurtisvgkurtisvg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pongad
pongad removed their request for review September 21, 2018 05:42
@frankyn

Copy link
Copy Markdown
ContributorAuthor

Merging for now and following up in a separate PR to resolve devex issues.

@frankyn
frankyn merged commit c55c3b7 into gcs-bucket-lock-readySep 22, 2018
@frankyn
frankyn deleted the gcs-bucket-lock-samples branch September 22, 2018 17:26
@frankynfrankyn mentioned this pull request Sep 25, 2018
frankyn added a commit that referenced this pull request Sep 28, 2018
* [Storage] Replay GCS Bucket Lock (#3645)
* Add support for defaultEventBasedHold
* Add support for Blob eventBasedHold
* Add support for blob temporary holds
* Remove Beta launch annotations for CMEK
* Add support for lockRetentionPolicy and RetentionPolicy
* Update FakeStorageRPC
* codacy-bot review fix (final only)
* Update getRetentionPolicyIsLocked() -> retentionPolicyIsLocked() and misc.
* Address comments
* Address comments
* Address comments.
* Small nits
* Fix additional comments
* [Storage] Bucket lock samples and bug fixes. (#3709)
* Fix issue in tests, write bucket lock samples, and resolve issue in client library
* Update documentation around Boolean returns to clarify different return caes.
* Fix broken unit test
* Address feedback
* Fix typo in comments
suztomo pushed a commit that referenced this pull request Mar 9, 2026
lqiu96 pushed a commit that referenced this pull request Mar 20, 2026
chingor13 pushed a commit that referenced this pull request Mar 24, 2026
A follow up of #3706:
- Change the group id to `com.google.cloud` as it is a customer-facing
library.
- Add clirr and enforcer check in CI.
chingor13 pushed a commit that referenced this pull request Mar 24, 2026
* feat: grpc metrics
* test
* grpc metrics env check
* skip test and clirr
* add grpc metrics in allowed metrics
* test: logs
* chore: generate libraries at Wed Apr 2 17:15:18 UTC 2025
* chore: generate libraries at Wed Apr 2 17:18:00 UTC 2025
* remove logs
* review
* clirr
* review comments
* enable grpc metrics only env is set to false
---------
Co-authored-by: cloud-java-bot <cloud-java-bot@google.com>
suztomo pushed a commit that referenced this pull request Mar 30, 2026
* [Storage] Replay GCS Bucket Lock (#3645)
* Add support for defaultEventBasedHold
* Add support for Blob eventBasedHold
* Add support for blob temporary holds
* Remove Beta launch annotations for CMEK
* Add support for lockRetentionPolicy and RetentionPolicy
* Update FakeStorageRPC
* codacy-bot review fix (final only)
* Update getRetentionPolicyIsLocked() -> retentionPolicyIsLocked() and misc.
* Address comments
* Address comments
* Address comments.
* Small nits
* Fix additional comments
* [Storage] Bucket lock samples and bug fixes. (#3709)
* Fix issue in tests, write bucket lock samples, and resolve issue in client library
* Update documentation around Boolean returns to clarify different return caes.
* Fix broken unit test
* Address feedback
* Fix typo in comments
lqiu96 pushed a commit that referenced this pull request Apr 1, 2026
* [Storage] Replay GCS Bucket Lock (#3645)
* Add support for defaultEventBasedHold
* Add support for Blob eventBasedHold
* Add support for blob temporary holds
* Remove Beta launch annotations for CMEK
* Add support for lockRetentionPolicy and RetentionPolicy
* Update FakeStorageRPC
* codacy-bot review fix (final only)
* Update getRetentionPolicyIsLocked() -> retentionPolicyIsLocked() and misc.
* Address comments
* Address comments
* Address comments.
* Small nits
* Fix additional comments
* [Storage] Bucket lock samples and bug fixes. (#3709)
* Fix issue in tests, write bucket lock samples, and resolve issue in client library
* Update documentation around Boolean returns to clarify different return caes.
* Fix broken unit test
* Address feedback
* Fix typo in comments
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@frankyn@kurtisvg@googlebot