【发布时间】:2020-05-20 15:15:38
【问题描述】:
我正在尝试使用 Python Client for Google Cloud Data Catalog API beta 1 来创建分类和策略标签。这是我的代码:
from google.cloud.datacatalog_v1beta1 import PolicyTagManagerClient, enums, types
from google.oauth2 import service_account
key_path = "./xxxxx.json"
credentials = service_account.Credentials.from_service_account_file(
key_path,
scopes=["https://www.googleapis.com/auth/cloud-platform"],
)
client = PolicyTagManagerClient(credentials=credentials)
resource_name = '//bigquery.googleapis.com/projects/{}/locations/us/taxonomies/{}'.format('3xxxxxxxx58','50xxxxxxxxx14')
taxonomy = client.get_taxonomy(resource_name)
print(taxonomy)
pt_taxonomy = types.Taxonomy()
pt_taxonomy.display_name = 'PHI'
response = client.create_taxonomy(parent=<project_id>, taxonomy=pt_taxonomy)
get_taxonomy() 出现以下错误
google.api_core.exceptions.MethodNotImplemented: 501 Operation is not implemented, or supported, or enabled.
对于 create_taxonomy() 我得到了:
"Received http2 header with status: 404","grpc_status":1,"value":"404"}"
有什么想法吗? 感谢您的帮助!
顺便说一句,google api 调用确实有效,它通过以下示例返回 200。
所以我将代码更改为:
pt_taxonomy1 = types.Taxonomy()
pt_taxonomy1.display_name = 'PHI1'
response = client.create_taxonomy('projects/39xxxxx/locations/us', pt_taxonomy1)
还是一样的501错误
【问题讨论】:
标签: google-cloud-platform google-api-python-client google-data-api