【发布时间】:2022-01-07 05:43:18
【问题描述】:
我正在尝试从下面提到的功能修补(更新)云调度程序中存在的作业。该函数使用 api 更新 Job 的属性(access_token)。但是它没有正确部署。代码有问题吗?
导入base64 从 pprint 导入 pprint
从 googleapiclient 导入发现 从 oauth2client.client 导入 GoogleCredentials
def hello_pubsub(event, context):
credentials = GoogleCredentials.get_application_default()
service = discovery.build('cloudscheduler', 'v1', credentials=credentials)
name = 'projects/XYZ/locations/TempLocation/jobs/TestTopic'
job_body = {
"name": "temp",
"description": temp,
"pubsubTarget": {
"topicName": "projects/XYZ/topics/TestTopic",
"attributes": {
"access_token": "blabla"
}
},
"httpTarget": {
"uri": "https://cloudscheduler.googleapis.com/v1/projects/XYZ/locations/TempLocation/jobs/TestTopic",
"httpMethod": "POST",
"headers": {
"Content-Type": "application/json",
},
"oauthToken": {
"serviceAccountEmail": "xyz@gmail.com",
}
}
}
request = service.projects().locations().jobs().patch(name=name, body=job_body)
response = request.execute()
pprint(response)
【问题讨论】:
-
这是我在日志中发现的错误 Downloading oauth2client-4.0.0-py2.py3-none-any.whl (184 kB) 错误:找不到满足 googleapiclient 要求的版本(来自 -r requirements.txt(第 4 行))(来自版本:无)错误:找不到 googleapiclient 的匹配分发(来自 -r requirements.txt(第 4 行));错误 ID:0ea8a540
标签: google-cloud-platform google-cloud-functions google-cloud-scheduler google-cloud-api-gateway