Skip to content

docs: Update all the samples targeting the BigtableTableAdminClient to use the generated layer instead#1710

Merged
kevkim-codes merged 68 commits intomainfrom
fix-restore-table-sample-3
Sep 9, 2025
Merged

docs: Update all the samples targeting the BigtableTableAdminClient to use the generated layer instead#1710
kevkim-codes merged 68 commits intomainfrom
fix-restore-table-sample-3

Conversation

@danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented Sep 3, 2025

Description

In this pull request we migrate the rest of the samples that use the handwritten layer which calls BigtableTableAdminClient under the hood to instead call the BigtableTableAdminClient directly. This is a follow-up PR to #1697.

Impact

This is a crucial step towards deprecating handwritten methods that use the admin client because it encourages users to start migrating their code over to using the admin clients directly.

Testing

This is a change to the samples so npm run samples-test is already a check in place that ensures these are correct.
We should consider extracting each sample into its own file and running each file just to ensure it does its job.

danieljbruce and others added 30 commits August 19, 2025 16:11
This commit updates the `backups.restore.js` sample to use the `BigtableTableAdminClient` directly for restoring a table from a backup, instead of going through the handwritten `bigtable.instance().createTableFromBackup()` method.

This change is based on the design document for the Node.js Bigtable Admin API autogeneration.

The corresponding test for the sample in `samples/test/backups.js` has also been updated to pass the correct arguments to the updated sample script.
instance of the admin client should be used
Copy link

@gkevinzheng gkevinzheng left a comment

Choose a reason for hiding this comment

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

Could we add a code sample for how to generate a polling harness for GenerateConsistencyToken -> CheckConsistency polling?

await operation.promise();
console.log(`Table restored to ${table.id} successfully.`);
const [table] = await operation.promise();

Choose a reason for hiding this comment

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

Do we want to document how to access the OptimizeRestoredTable LRO here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment here for that.

Choose a reason for hiding this comment

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

I'm not sure a comment here covers accessing the OptimizeRestoredTable LRO after the RestoreTable LRO finishes. In Python, we had to read the RestoreTableMetadata, use the GAPIC operation client to get the LRO pointed to by the optimize_table_operation_name field in the LRO metadata, then return that to the user so they could await that.

I think your sample should either encompass all of that or expose a field/function to the user that abstracts all of that away.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. Could you add a section that awaits the optimized table token and uses that to restore the table?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a line for adding the optimized table.

Copy link
Contributor Author

@danieljbruce danieljbruce Sep 8, 2025

Choose a reason for hiding this comment

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

See this link for more context.

@snippet-bot
Copy link

snippet-bot bot commented Sep 4, 2025

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

@danieljbruce
Copy link
Contributor Author

Could we add a code sample for how to generate a polling harness for GenerateConsistencyToken -> CheckConsistency polling?

I added a commit here for that.

…into fix-restore-table-sample-3

# Conflicts:
#	samples/api-reference-doc-snippets/backups.restore.js
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Sep 8, 2025
name: optimizeTableOperationName,
});
}
console.log(

Choose a reason for hiding this comment

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

You need to also await the OptimizeRestoreTable LRO in addition to awaiting getting the operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The while loop intends to wait until the optimize restore table operation is complete. I'm not sure if Node has a method out of the box that lets us get an LRO for optimize restore table so we do the equivalent which involves getting the operation until operation.done is true.

@danieljbruce danieljbruce added the automerge Merge the pull request once unit tests and other checks pass. label Sep 8, 2025
@kevkim-codes kevkim-codes merged commit cf04e10 into main Sep 9, 2025
20 of 23 checks passed
@kevkim-codes kevkim-codes deleted the fix-restore-table-sample-3 branch September 9, 2025 00:27
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the googleapis/nodejs-bigtable API. samples Issues that are directly related to samples. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants