- Notifications
You must be signed in to change notification settings - Fork321
feat: addfields parameter toset_iam_policy for consistency with update methods#1872
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright 2024 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| deftest_create_iam_policy(table_id:str): | ||
| your_table_id=table_id | ||
| # [START bigquery_create_iam_policy] | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| fromgoogle.cloudimportbigquery | ||
| bqclient=bigquery.Client() | ||
| policy=bqclient.get_iam_policy( | ||
| your_table_id,# e.g. "project.dataset.table" | ||
| ) | ||
| analyst_email="example-analyst-group@google.com" | ||
| binding= { | ||
| "role":"roles/bigquery.dataViewer", | ||
| "members": {f"group:{analyst_email}"}, | ||
| } | ||
| policy.bindings.append(binding) | ||
| updated_policy=bqclient.set_iam_policy( | ||
| your_table_id,# e.g. "project.dataset.table" | ||
| policy, | ||
| ) | ||
| forbindinginupdated_policy.bindings: | ||
| print(repr(binding)) | ||
| # [END bigquery_create_iam_policy] | ||
| assertbindinginupdated_policy.bindings | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -36,7 +36,6 @@ | ||
| from google.api_core.exceptions import InternalServerError | ||
| from google.api_core.exceptions import ServiceUnavailable | ||
| from google.api_core.exceptions import TooManyRequests | ||
| from google.cloud import bigquery | ||
| from google.cloud.bigquery.dataset import Dataset | ||
| from google.cloud.bigquery.dataset import DatasetReference | ||
| @@ -1485,33 +1484,6 @@ def test_copy_table(self): | ||
| got_rows = self._fetch_single_page(dest_table) | ||
| self.assertTrue(len(got_rows) > 0) | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This test is now redundant with a code sample which serves the same purpose with regards to testing. | ||
| def test_test_iam_permissions(self): | ||
| dataset = self.temp_dataset(_make_dataset_id("create_table")) | ||
| table_id = "test_table" | ||