有没有办法使用 python 使用 googleapiclient 创建带有 pubsub 通知的计划查询?
Is there a way to create a scheduled query with pubsub notification using googleapiclient using python?
我想使用 Python 创建动态计划查询,并且我想在查询完成时在 PubSub 上发布消息。我知道我可以从 UI 做到这一点,但这不是我想要的。
目前我正在这样做,但是 "notificationPubsubTopic" 字段在请求中被忽略
import googleapiclient.http
from googleapiclient import discovery, errors
resource = discovery.build("bigquerydatatransfer", "v1")
body = {
"notificationPubsubTopic": "projects/{my_project}/topics/{my_topic}",
"scheduleOptions": {
"disableAutoScheduling": False
},
"disabled": False,
"displayName": "my_table_name",
"dataSourceId": "scheduled_query",
"destinationDatasetId": "test",
"emailPreferences": {
"enableFailureEmail": False
},
"params": {
"query": "select 1",
"write_disposition": "WRITE_TRUNCATE",
"destination_table_name_template": "table_name_test"
},
"schedule": "every day 09:35"
}
creation_job = res.projects().transferConfigs().create(parent=project, body=body)
creation_job.execute()
Google 前几天发布了 datatransfer
library 的新版本,在创建传输配置时添加了对 notification_pubsub_topic
的支持。
我想使用 Python 创建动态计划查询,并且我想在查询完成时在 PubSub 上发布消息。我知道我可以从 UI 做到这一点,但这不是我想要的。
目前我正在这样做,但是 "notificationPubsubTopic" 字段在请求中被忽略
import googleapiclient.http
from googleapiclient import discovery, errors
resource = discovery.build("bigquerydatatransfer", "v1")
body = {
"notificationPubsubTopic": "projects/{my_project}/topics/{my_topic}",
"scheduleOptions": {
"disableAutoScheduling": False
},
"disabled": False,
"displayName": "my_table_name",
"dataSourceId": "scheduled_query",
"destinationDatasetId": "test",
"emailPreferences": {
"enableFailureEmail": False
},
"params": {
"query": "select 1",
"write_disposition": "WRITE_TRUNCATE",
"destination_table_name_template": "table_name_test"
},
"schedule": "every day 09:35"
}
creation_job = res.projects().transferConfigs().create(parent=project, body=body)
creation_job.execute()
Google 前几天发布了 datatransfer
library 的新版本,在创建传输配置时添加了对 notification_pubsub_topic
的支持。