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

feat(storage): add quickstart sample for storage control #2621

Merged
merged 3 commits into from
May 8, 2024

Conversation

JesseLovelace
Copy link
Member

Adds a quickstart sample for storage control

@JesseLovelace JesseLovelace requested review from a team as code owners May 6, 2024 18:24
Copy link

snippet-bot bot commented May 6, 2024

Here is the summary of changes.

You are about to add 1 region tag.

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 api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels May 6, 2024
Copy link
Member

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

This looks good, but I wonder if we should create a separate folder for Storage control? I think we should.

Copy link
Member

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

I don't know whether @amanda-tarafa has different preferences in terms of resource name usage and overloads vs request objects.

StorageControlClient storageControl = StorageControlClient.Create();
GetStorageLayoutRequest request = new GetStorageLayoutRequest
{
Name = StorageLayoutName.Format("_", bucketName), // Set project to "_" for global bucket"
Copy link
Member

Choose a reason for hiding this comment

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

Rather than explicitly formatting to a string, I'd set the StorageLayoutName property instead (if you really need a request object - see below):

GetStorageLayoutRequest request = new GetStorageLayoutRequest
{
    StorageLayoutName = new StorageLayoutName("_", bucketName");
}

Copy link
Member

Choose a reason for hiding this comment

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

Yes +1 to this.

{
Name = StorageLayoutName.Format("_", bucketName), // Set project to "_" for global bucket"
};
StorageLayout response = storageControl.GetStorageLayout(request);
Copy link
Member

Choose a reason for hiding this comment

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

This is a relatively long-winded way of doing things. We generate an overload accepting the name:

StorageLayout response = storageControl.GetStorageLayout(new StorageLayoutName("_", bucket));

(By all means separate out the StorageLayoutName initialization to a separate variable.)

Copy link
Member

Choose a reason for hiding this comment

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

There is a sample guideline, or at least there used to be one, about showing the request object overload for most samples. This is meant to be a hint for users that "there's likely more you can do".

I'm usually lenient with whatever approach is used, so I'm fine either way. I agree that it is more legible to use the simpler overload though, if that's enough.

@JesseLovelace
Copy link
Member Author

@amanda-tarafa, about your comment regarding a separate folder: I'm basing this off of the other client libraries that have implemented this so far, which have it within the storage samples folder (https://github.com/googleapis/java-storage/pull/2479/files), (https://github.com/GoogleCloudPlatform/golang-samples/pull/3988/files)

amanda-tarafa
amanda-tarafa previously approved these changes May 8, 2024
storage/api/Storage.Samples/StorageControlQuickstart.cs Outdated Show resolved Hide resolved
@amanda-tarafa amanda-tarafa merged commit 2994f40 into main May 8, 2024
10 checks passed
@amanda-tarafa amanda-tarafa deleted the controlqs branch May 8, 2024 07:25
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 Cloud Storage API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants