我想创建一个每天上午 10 点运行的 cron 作业以触发云功能。但是,我遇到了 Python api 的问题。当我创建工作时,它会弹出此错误。
TypeError:MergeFrom() 的参数必须是同一类的实例:预期的 google.cloud.scheduler.v1.HttpTarget 得到了 str。
这是我的代码:
from google.cloud import scheduler_v1
project_id = XXXX
client = scheduler_v1.CloudSchedulerClient.from_service_account_json(
r"./xxxx.json")
parent= client.location_path(project_id,'us-central1')
job={"name":"traing_for_model",
"description":"this is for testing training model",
"http_target":"https://us-central1-xxxx-test.cloudfunctions.net/automl-trainmodel-1-test-for-cron-job",
"schedule":"1 0 * * *",
"time_zone":"utc+8",
}
training_job= client.create_job(parent,job)