[Storage] Bucket lock samples and bug fixes.#3709
[Storage] Bucket lock samples and bug fixes.#3709frankyn merged 4 commits intogcs-bucket-lock-readyfrom
Conversation
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
...ud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
Show resolved
Hide resolved
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return bucket; | ||
| } | ||
|
|
||
| Bucket updated_bucket = bucket.toBuilder().setRetentionPeriod(null).build().update(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
...oud-examples/src/test/java/com/google/cloud/examples/storage/snippets/ITStorageSnippets.java
Show resolved
Hide resolved
|
Comments addressed. @kurtisvg PTAL |
|
Merging for now and following up in a separate PR to resolve devex issues. |
* [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
Bug fixes from sample review
Samples