Skip to content

Instantly share code, notes, and snippets.

@idoshamun
Last active June 12, 2016 12:52
Show Gist options
  • Save idoshamun/e49f7a99622022f97c844307bbed0215 to your computer and use it in GitHub Desktop.
Save idoshamun/e49f7a99622022f97c844307bbed0215 to your computer and use it in GitHub Desktop.
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