Created
April 22, 2014 22:53
-
-
Save ethanmick/11197168 to your computer and use it in GitHub Desktop.
Give an App ID and the master token - delete's all users and optionally all app data as well.
This file contains hidden or 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
# | |
# Requires you to run 'gem install httparty' | |
# | |
require 'httparty' | |
def main | |
appId = ARGV[0] | |
masterKey = ARGV[1] | |
delete_data = ARGV[2] ? ARGV[2] == "true" : false | |
usage() and return if not appId or not masterKey | |
url = "https://api.cloudmine.me/v1/app/" + appId.to_s | |
accountUrl = url + "/account" | |
response = HTTParty.get(accountUrl, :headers => {"X-CloudMine-ApiKey" => masterKey}) | |
puts "response: #{response}" | |
response["success"].each_key do |user| | |
delete = HTTParty.delete(accountUrl + "/" + user, :headers => {"X-CloudMine-ApiKey" => masterKey}) | |
puts "Deleted user: #{user}" | |
end | |
if delete_data | |
data = HTTParty.delete(url + "/data?all=true", :headers => {"X-CloudMine-ApiKey" => masterKey}) | |
puts "Deleted all app data. #{data}" | |
end | |
end | |
def usage | |
puts "usage: 'ruby delete_all_users.rb appid masterkey [delete_app_data[true/false]'" | |
true | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment