【发布时间】:2020-12-08 10:10:02
【问题描述】:
我想在 Google Cloud Platform 中使用 Cloud Function 触发数据流。
在 Cloud Function 中,我使用 Python 像这样调用 API:
from googleapiclient.discovery import build
service = build('dataflow', 'v1b3', cache_discovery=False)
request = service.projects().locations().templates().launch(
projectId=projectId, gcsPath=srcDataFlowTemplate, location='us', body={
'jobName': jobName,
'parameters': parameters,
'environment':environment
}
)
response = request.execute()
这是我正在启动的数据流模板中的管道:
(p
| 'Create PCollection' >> beam.Create(inputFile)
| 'Read from a File' >> beam.io.ReadAllFromText(skip_header_lines=1)
| 'Write to BigQuery' >> beam.io.Write(beam.io.WriteToBigQuery (table,
project=projectId,
dataset=dataset,
schema=schema,
create_disposition=beam.io.BigQueryDisposition.CREATE_IF_NEEDED,
write_disposition=beam.io.BigQueryDisposition.WRITE_APPEND
)
)
)
在数据流模板中 - 是否可以从 API 调用中提取存储在请求正文中的参数属性和 projectId 下的这个“inputFile”?
【问题讨论】:
-
你能列出你想要的变量吗?为什么?我可以很容易地得到一些,其他的更难,我想在深入研究之前确定!
-
我已经更新了我的问题。我是这个环境的新手,所以我不知道这是否可能。我基本上想在拨打此电话后在 DataFlow 模板中提取此 {projectId}:https://dataflow.googleapis.com/v1b3/projects/{projectId}/templates:launch
标签: google-cloud-platform apache-beam google-apis-explorer