簡體   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