简体   繁体   中英

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

How to delete a task from Google Task queue programmatically using Node.js ?

Documentation doesn't tell us anything about it in Node.js

Task Queue Link

I found this documentation and this one that mention how to delete the task. Only please keep in mind that a task cannot be deleted if it has executed successfully or permanently failed.

This is the code that the Google's documentation mentions :

 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(); }

I really hope that this information helps you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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