Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add samples for object retention #2417

Merged
merged 13 commits into from Feb 26, 2024
Merged

docs: add samples for object retention #2417

merged 13 commits into from Feb 26, 2024

Conversation

JesseLovelace
Copy link
Contributor

Adds object retention samples and tests

Copy link

snippet-bot bot commented Feb 15, 2024

Here is the summary of changes.

You are about to add 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/java-storage API. samples Issues that are directly related to samples. labels Feb 15, 2024
@JesseLovelace JesseLovelace requested review from a team as code owners February 15, 2024 21:44
@@ -68,6 +68,7 @@ public static void getObjectMetadata(String projectId, String bucketName, String
System.out.println("StorageClass: " + blob.getStorageClass());
System.out.println("TimeCreated: " + new Date(blob.getCreateTime()));
System.out.println("Last Metadata Update: " + new Date(blob.getUpdateTime()));
System.out.println("Object Retention Policy: " + blob.getRetention());
Copy link
Member

Choose a reason for hiding this comment

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

GetBucketMetadata and this sample are missing test changes; please add them.

import com.google.cloud.storage.StorageOptions;

public class CreateBucketWithObjectRetention {
public static void createBucketWithObjectRetention(String projectId, String bucketName) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this sample required in docs? Wondering if users could be pointed to `BucketTargetOption.enableObjectRetention(true) instead of writing this sample in 8 languages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's meant to go here: https://cloud.google.com/storage/docs/using-object-lock#enable-retentions

We want to have a sample for every use case on this page

Copy link
Member

Choose a reason for hiding this comment

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

sg, thanks for clarifying.

System.out.println(updated.getRetention().toString());

// To modify an existing policy on an Unlocked object, pass in the override parameter
blob.toBuilder()
Copy link
Member

Choose a reason for hiding this comment

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

This looks like two samples in one; were you planning on splitting it or keeping as-is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Planning to keep as is. I think it's important that a user sees both cases, so keeping them in one sample makes sure that it can't be missed.

@JesseLovelace JesseLovelace merged commit 45837d3 into main Feb 26, 2024
22 checks passed
@JesseLovelace JesseLovelace deleted the objlocksamples branch February 26, 2024 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. samples Issues that are directly related to samples. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants