有没有办法通过“Cloud Scheduler”运行admin api方法“Patch”?
通过API Explorer运行时,我的功能非常有效。
w / servingStatus作为updateMask,这作为请求体
{
"servingStatus": "USER_DISABLED"
}
但是如果我通过云调度程序运行请求,那么在我希望它运行时,我会收到404错误。
Target : HTTP
URL : https://appengine.googleapis.com/v1/apps/[APP-ID]/services/default/?updateMask=servingStatus
POST BODY :
{
"servingStatus": "USER_DISABLED"
}
我可能有错误的url语法,但我找不到任何与我得到的不同的东西。
注意:我的目标是在特定时间关闭服务器。
从创建调度程序作业的当前文档找到here,如果我们查看--http-method
标志,我们发现它被记录为限制为以下之一:
显然,我们没有看到patch
。确认patch
是正确的HTTP命令,我们看起来here,确实看到这是正确的。
可能对我们有价值的下一个想法是认识到Cloud Scheduler可以触发HTTP或PubSub事件,并且实际上并不关心该事件的目标位置。这意味着我们可以创建一个云功能,它封装了这样的想法:当调用云功能时,它会封装您所需的服务器关闭。如果Cloud Function拥有关闭功能,那么这个难题将从我们如何驱动Cloud Scheduler调用AppEngine Admin Api变为我们如何调用拥有关闭服务器的云功能?这更容易,也可能更强大。您可以将云功能配置为通过GET或POST响应REST请求,并让Cloud Scheduler提交该请求。
在使用Appengine API之前,有必要使用文档中描述的complete preliminary steps:
请检查quick start how to use Cloud Scheduler。还有信息what API you need to enable。
Cloud Scheuler API的正确范围是https://cloudscheduler.googleapis.com
还有信息how to use PATCH request,应该是这样的:
PATCH
https://cloudscheduler.googleapis.com/v1/{job.name=projects/*/locations/*/jobs/*}