Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

samples: Add example on creating instance with tags - #2837

Merged
gcf-merge-on-green[bot] merged 10 commits into
googleapis:mainfrom
dohun-dev:docs2
May 6, 2026
Merged

samples: Add example on creating instance with tags#2837
gcf-merge-on-green[bot] merged 10 commits into
googleapis:mainfrom
dohun-dev:docs2

Conversation

@dohun-dev

@dohun-devdohun-dev commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Rollback plan is reviewed and LGTMed
  • All new data plane features have a completed end to end testing plan

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

This is dependent on 2.75.0 #2832

@product-auto-labelproduct-auto-labelBot added size: m Pull request size is medium. api: bigtable Issues related to the googleapis/java-bigtable API. samples Issues that are directly related to samples. labels Mar 10, 2026
Comment on lines +152 to +153
* <p>Tags are a way to organize and govern resources across Google Cloud, see:
* https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace addresses with Markdown links: [Creating and managing tags](https://docs.cloud.google.com/bigtable/docs/tags), same change on lines 158, 159.

Correct links are: https://docs.cloud.google.com/bigtable/docs/tags, https://docs.cloud.google.com/resource-manager/docs/tags/tags-overview

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done

* https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing
*
*
* NOTE: Unlike Labels, a Tag (Key and Value) must be created before it can be

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: labels, tag, key, value are not proper names, hence we spell them in lowercase.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

* https://docs.cloud.google.com/bigtable/docs/tags for more information.
*/
public void createProdInstanceWithTags() {
// Checks if instance exists, creates instance if does not exists.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if doesn't exist.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

@dohun-dev
dohun-dev marked this pull request as ready for review March 10, 2026 17:48
@dohun-dev
dohun-devforce-pushed the docs2 branch 2 times, most recently from 851c7eb to 984a1d0CompareApril 9, 2026 20:52

public void run() {
createProdInstance();
/* * OPTIONAL: Testing with tags

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.

Alternatively, can we pass in an additional argument in main() to create instance with tag?

And looks like createProdInstance() and createProdInstanceWithTags are almost identical. I think you can pass the bool as an param:

main(String[] args) {
String projectId = args[0];
boolean createWithTag = false;
if (args.size() > 1) {
boolean createWithTag = Boolean.parseBoolean(args[1]);
}
... instanceAdmin.run(createWithTag);
}
run(boolean createWithTag) {
createProdInstance(createWithTag);
...
}
createProdInstance(boolean createWithTag) {
...
Instance.Builder instanceObjBuilder =
Instance.newBuilder()
.setDisplayName(instanceId)
.setType(Instance.Type.PRODUCTION)
.putLabels("department", "accounting");
if (createWithTag) {
instanceObjBuilder.putTags(tagKey, tagValue);
}
Instance instanceObj = instanceObjBuilder.build()
...
}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

That sounds good. I made the change. Also, this PR is dependent on #2832. Should that version update to 2.75 in the pom.xml file be included in this CL or is that usually done separately?

@mutianf

Copy link
Copy Markdown
Contributor

/gcbrun

nimf
nimf approved these changes May 5, 2026
@mutianf

Copy link
Copy Markdown
Contributor

/gcbrun

@mutianfmutianf added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 5, 2026
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 5, 2026
@dohun-dev

Copy link
Copy Markdown
ContributorAuthor

/gcbrun

@mutianf

Copy link
Copy Markdown
Contributor

/gcbrun

@mutianfmutianf added the kokoro:run Add this label to force Kokoro to re-run the tests. label May 6, 2026
@mutianfmutianf added the automerge Merge the pull request once unit tests and other checks pass. label May 6, 2026
@yoshi-kokoroyoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label May 6, 2026
@mutianfmutianf added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 6, 2026
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 6, 2026
@mutianfmutianf added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 6, 2026
@yoshi-kokoroyoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 6, 2026
@gcf-merge-on-green
gcf-merge-on-greenBot merged commit 5a45afa into googleapis:mainMay 6, 2026
25 checks passed
@gcf-merge-on-greengcf-merge-on-greenBot removed the automerge Merge the pull request once unit tests and other checks pass. label May 6, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigtableIssues related to the googleapis/java-bigtable API.samplesIssues that are directly related to samples.size: mPull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@dohun-dev@mutianf@nimf@KasiaStrz@grayside@yoshi-kokoro