Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete all Google Pub/Sub subscriptions
'use strict';
const async = require('async');
const gcloud = require('gcloud')();
const pubsub = gcloud.pubsub();
const callback = function (err, subscriptions, nextQuery) {
if (!err) {
async.forEach(subscriptions, (subscription, callback) => {
subscription.delete(callback);
}, err => {
if (err) {
console.error('something went wrong!');
console.error(err);
}
else {
if (nextQuery) {
pubsub.getSubscriptions(nextQuery, callback);
}
else {
process.exit();
}
}
})
}
};
pubsub.getSubscriptions({
autoPaginate: false
}, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment