Last active
June 12, 2016 12:52
-
-
Save idoshamun/e49f7a99622022f97c844307bbed0215 to your computer and use it in GitHub Desktop.
Delete all Google Pub/Sub subscriptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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