繁体   English   中英

如何使用 Node.js 以编程方式从 Google 任务队列中删除 Google 任务?

[英]How to delete Google task from Google Task queue programmatically using Node.js?

如何使用Node.js 以编程方式从 Google 任务队列中删除任务?

文档在 Node.js 中没有告诉我们任何关于它的信息

任务队列链接

我发现这个文件这一个提及如何删除任务。 请记住,如果任务已成功执行或永久失败,则无法删除该任务

这是谷歌文档中提到的代码:

 const {google} = require('googleapis'); const cloudtasks = google.cloudtasks('v2beta3'); async function main () { const authClient = await authorize(); const request = { // Required. The task name. For example: // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` name: 'projects/my-project/locations/my-location/queues/my-queue/tasks/my-task', // TODO: Update placeholder value. auth: authClient, }; try { await cloudtasks.projects.locations.queues.tasks.delete(request); } catch (err) { console.error(err); } } main(); async function authorize() { const auth = new google.auth.GoogleAuth({ scopes: ['https://www.googleapis.com/auth/cloud-platform'] }); return await auth.getClient(); }

我真的希望这些信息对您有所帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM