gcp datacatalog_v1beta1创建分类法和策略标签失败

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

我正在尝试使用适用于Google Cloud Data Catalog API beta 1的Python客户端来创建分类和策略标签。这是我的代码:

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"}"

任何想法?谢谢您的帮助!

BTW google api调用确实起作用,下面的示例返回200。

enter image description here

所以我将代码更改为:

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
1个回答
0
投票

从文档click here,请注意,此处已描述错误消息NOT_IMPLEMENTED(501)。我猜您需要在client.get_taxonomy()上使用诸如project_id,region和cluster之类的参数,因为资源具有这些参数。您可以查看文章click here了解授权范围,也可以查看click here了解API方法。

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