如何重置附加到bigquery列的策略标签?

问题描述 投票:0回答:1

我正在使用脚本将策略标签设置为 bigquery 列(例如名称列),但我不知道如何继续使用 Python 脚本回滚此更改


from google.cloud import bigquery
from google.cloud.bigquery.schema import SchemaField,PolicyTagList
client = bigquery.Client()

table_id = 'project_id.dataset_id.table_id'

policy_tags = PolicyTagList(names=["projects/<my_project_id>/locations/us/taxonomies/<taxonomy_id>/policyTags/<policy_tag_id>"])
table = client.get_table(table_id)

table.schema = [
        SchemaField(
            name="name",
            field_type="STRING",
            policy_tags=policy_tags
            ),
        SchemaField(
            name="age",
            field_type="INT64"
            )
        ]

table = client.update_table(table=table,fields=["schema"])
print(table.schema)

提前致谢!

我尝试使用policy_tags=None,但它不起作用(附加的策略不会从列中删除)

https://cloud.google.com/bigquery/docs/column-level-security#api_5

google-cloud-platform google-bigquery google-api-python-client
1个回答
0
投票

policy_tags = PolicyTagList(names="")

成功了!

© www.soinside.com 2019 - 2024. All rights reserved.