I am trying to use Python Client for Google Cloud Data Catalog API beta 1 to create taxonomy and policy tags. here is my code:
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)
I get following error for get_taxonomy()
google.api_core.exceptions.MethodNotImplemented: 501 Operation is not implemented, or supported, or enabled.
and for create_taxonomy() I got:
"Received http2 header with status: 404","grpc_status":1,"value":"404"}"
any idea? Thank you for your help!
BTW google api call does work, it returns 200 with following example.
So I changed my code to:
pt_taxonomy1 = types.Taxonomy()
pt_taxonomy1.display_name = 'PHI1'
response = client.create_taxonomy('projects/39xxxxx/locations/us', pt_taxonomy1)
still same 501 error

From the docs click here, noticed that the error message NOT_IMPLEMENTED (501) has been described here. I guess you need to use parameters on client.get_taxonomy() like project_id, region and cluster as resources have these parameters. You can look in to the article click here for authorization scope and also click here for API method.