Reputation: 849
How to delete a task from Google Task queue programmatically using Node.js?
Documentation doesn't tell us anything about it in Node.js
Upvotes: 2
Views: 553
Reputation: 820
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 :)
Upvotes: 1