Skip to content

Conversation

@hivanalejandro
Copy link
Contributor

@hivanalejandro hivanalejandro commented Feb 13, 2025

Description

Add sample for viewing access policy to dataset

This PR has been divided into the following 3:

#4023
#4024
#4025

Step of Internal: b/394478489

  1. bigquery_view_dataset_access policy
  2. bigquery_view_table_or_view_access_policy
  3. bigquery_grant_access_to_dataset
  4. bigquery_grant_access_to_table_or_view
  5. bigquery_revoke_dataset_access
  6. bigquery_revoke_access_to_table_or_view

Checklist

- Configure main app.js entry point
- Configure viewDatasetAccessPolicy.js file
- Add viewTableOrViewAccessPolicy to the app.js entry point
- Configure viewTableOrViewAccessPolicy.js file
@hivanalejandro hivanalejandro requested review from a team as code owners February 13, 2025 20:01
@snippet-bot
Copy link

snippet-bot bot commented Feb 13, 2025

Here is the summary of changes.

You are about to add 6 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 api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples. labels Feb 13, 2025
@hivanalejandro hivanalejandro marked this pull request as draft February 13, 2025 20:01
@hivanalejandro hivanalejandro changed the title feat(bigquery): WIP create sample 'viewTableOrViewAccessPolicy' & 'viewDatasetAccessPolicy' feat(bigquery): WIP feat(bigquery): add samples for access policies Feb 20, 2025
@hivanalejandro hivanalejandro changed the title feat(bigquery): WIP feat(bigquery): add samples for access policies feat(bigquery): WIP add samples for access policies Feb 20, 2025
Copy link
Contributor

@eapl-gemugami eapl-gemugami left a comment

Choose a reason for hiding this comment

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

I left a few comments. Please let me know if you require further details.

Copy link
Contributor

@eapl-gemugami eapl-gemugami left a comment

Choose a reason for hiding this comment

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

I'm leaving a few comments, let me know if you need further details!

Copy link
Contributor

@eapl-gemugami eapl-gemugami left a comment

Choose a reason for hiding this comment

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

A few comments for the latest commit.

@hivanalejandro hivanalejandro marked this pull request as ready for review March 5, 2025 16:56
Copy link
Contributor

@eapl-gemugami eapl-gemugami left a comment

Choose a reason for hiding this comment

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

I'm sharing a few comments on Sample formatting and scope of used variables inside the region/block.

"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I've seen, the author should be 'Google LLC', as in:

// Copyright 2020 Google LLC

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 was checking the package.json files of other samples and all of them have Google Inc. in the author part.

Copy link
Contributor

@eapl-gemugami eapl-gemugami Mar 6, 2025

Choose a reason for hiding this comment

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

These reference package.json files using Google Inc. might be outdated, see renderer/package.json#L6 from 2020 or retail/package.json#L4) from 2021

Also check b/169619920

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, you could ask your NodeJS lead for advice.

Copy link
Contributor

@eapl-gemugami eapl-gemugami left a comment

Choose a reason for hiding this comment

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

Comments for minor details found in last commit.

"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
Copy link
Contributor

@eapl-gemugami eapl-gemugami Mar 6, 2025

Choose a reason for hiding this comment

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

These reference package.json files using Google Inc. might be outdated, see renderer/package.json#L6 from 2020 or retail/package.json#L4) from 2021

Also check b/169619920

"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, you could ask your NodeJS lead for advice.

}

if (principalToRemove) {
// The `bindings` list is immutable. Create a copy for modifications.
Copy link
Contributor

@eapl-gemugami eapl-gemugami Mar 6, 2025

Choose a reason for hiding this comment

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

Question:
I added that comment on the Python Sample to warn the developer that they can't modify the list but have to create a new one, as working on the current list was the 'obvious' thing to do.

That was required on Python, after some research on the source code and struggling to make the sample work, is it the same case for Node?
My only concern would be to create a new list if it's not necessary on Node cloud-client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike Python, creating a new list in Node is not strictly necessary for this operation to work. JS doesn't have the same restrictions as Python when modifying list during iteration.

However, creating a copy with const bindings = [...policy.bindings]; is still recommended because it prevents potential issues if the BQ Node client has any internal expectations about immutability of the policy object.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for the record: Besides having problems modifying a list during an iteration, the list on Python is immutable due to the way the bindings were designed:
iam.py#L141-L148

From what I can see here types.d.ts#L3683 and there types.d.ts#L1752-L1756, Node client is more relaxed on how to work the list, but I can't confirm if it's immutable.

Anyway, if you are not sure about the binding list being immutable, to avoid misleading the developer you could just leave:
// Create a copy of the binding list for modifications.

@hivanalejandro hivanalejandro changed the title feat(bigquery): WIP add samples for access policies feat(bigquery): Add cloud-client samples for access policies Mar 7, 2025
Copy link
Contributor

@eapl-gemugami eapl-gemugami left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants