KEMBAR78
docs: add samples for object retention by JesseLovelace · Pull Request #2417 · googleapis/java-storage · GitHub
Skip to content

Conversation

@JesseLovelace
Copy link
Contributor

Adds object retention samples and tests

@snippet-bot
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
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
Contributor

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
Contributor

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
Contributor

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
Contributor

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
@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.

3 participants