|
15 | 15 | from google.api_core.iam import Policy |
16 | 16 |
|
17 | 17 |
|
18 | | -def view_table_or_view_access_policy(project_id: str, dataset_id: str, resource_name: str) -> Policy: |
| 18 | +def view_table_or_view_access_policy(project_id: str, dataset_id: str, resource_id: str) -> Policy: |
19 | 19 | # [START bigquery_view_table_or_view_access_policy] |
20 | | - # Imports the Google Cloud client library |
| 20 | + # Imports the Google Cloud client library. |
21 | 21 | from google.cloud import bigquery |
22 | 22 |
|
23 | | - # TODO(developer): Update and un-comment below lines |
| 23 | + # TODO(developer): Update and uncomment the lines below. |
| 24 | + |
24 | 25 | # Google Cloud Platform project. |
25 | 26 | # project_id = "my_project_id" |
| 27 | + |
26 | 28 | # Dataset where the table or view is. |
27 | 29 | # dataset_id = "my_dataset_id" |
28 | | - # Table or view name to get the access policy. |
29 | | - # resource_name = "my_table_name" |
| 30 | + |
| 31 | + # Table or view from which to get the access policy. |
| 32 | + # resource_id = "my_table_id" |
30 | 33 |
|
31 | 34 | # Instantiate a client. |
32 | 35 | client = bigquery.Client() |
33 | 36 |
|
34 | | - # Get the full table or view name. |
35 | | - full_resource_name = f"{project_id}.{dataset_id}.{resource_name}" |
| 37 | + # Get the full table or view id. |
| 38 | + full_resource_id = f"{project_id}.{dataset_id}.{resource_id}" |
36 | 39 |
|
37 | 40 | # Get the IAM access policy for the table or view. |
38 | | - policy = client.get_iam_policy(full_resource_name) |
| 41 | + policy = client.get_iam_policy(full_resource_id) |
39 | 42 |
|
40 | 43 | # Show policy details. |
41 | 44 | # Find more details for the Policy object here: |
42 | 45 | # https://cloud.google.com/bigquery/docs/reference/rest/v2/Policy |
43 | | - print(f"Access Policy details for table or view '{resource_name}'.") |
| 46 | + print(f"Access Policy details for table or view '{resource_id}'.") |
44 | 47 | print(f"Bindings: {policy.bindings}") |
45 | 48 | print(f"etag: {policy.etag}") |
46 | 49 | print(f"Version: {policy.version}") |
|
0 commit comments