Skip to content

Instantly share code, notes, and snippets.

@ethanmick
Created April 22, 2014 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanmick/11197168 to your computer and use it in GitHub Desktop.
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.
#
# 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