gem install discloud
API > User
require "discloud"
client = Discloud::Client.new(token: "API-TOKEN")
user = Discloud::Resources::User.new(client)
puts "== USER INFO =="
begin
response = user.info
pp response.parsed_response
rescue => e
puts "[Error getting user information] \#{e.message}"
end
puts "\n== SET LOCALE =="
begin
locale_response = user.set_locale("en-US")
pp locale_response.parsed_response
rescue => e
puts "[Error changing locale] \#{e.message}"
end
API > App
require "discloud"
client = Discloud::Client.new(token: "API-TOKEN")
app = Discloud::Resources::App.new(client)
app_id = "YOUR_APP_ID"
zip_path = "path/to/app.zip"
puts "== APP INFO =="
begin
response = app.info(app_id)
pp response.parsed_response
rescue => e
puts "[Error getting app info] \#{e.message}"
end
puts "\n== APP STATUS =="
begin
response = app.status(app_id)
pp response.parsed_response
rescue => e
puts "[Error getting app status] \#{e.message}"
end
puts "\n== APP LOGS =="
begin
response = app.logs(app_id)
pp response.parsed_response
rescue => e
puts "[Error fetching app logs] \#{e.message}"
end
puts "\n== APP BACKUP =="
begin
response = app.backup(app_id)
pp response.parsed_response
rescue => e
puts "[Error downloading app backup] \#{e.message}"
end
puts "\n== START APP =="
begin
response = app.start(app_id)
pp response.parsed_response
rescue => e
puts "[Error starting app] \#{e.message}"
end
puts "\n== RESTART APP =="
begin
response = app.restart(app_id)
pp response.parsed_response
rescue => e
puts "[Error restarting app] \#{e.message}"
end
puts "\n== STOP APP =="
begin
response = app.stop(app_id)
pp response.parsed_response
rescue => e
puts "[Error stopping app] \#{e.message}"
end
puts "\n== CHANGE APP RAM =="
begin
response = app.change_ram(app_id, 512)
pp response.parsed_response
rescue => e
puts "[Error changing RAM] \#{e.message}"
end
puts "\n== COMMIT APP =="
begin
response = app.commit(app_id, zip_path)
pp response.parsed_response
rescue => e
puts "[Error committing app] \#{e.message}"
end
puts "\n== UPLOAD APP =="
begin
response = app.upload(zip_path)
pp response.parsed_response
rescue => e
puts "[Error uploading app] \#{e.message}"
end
puts "\n== DELETE APP =="
begin
response = app.delete(app_id)
pp response.parsed_response
rescue => e
puts "[Error deleting app] \#{e.message}"
end
puts "\n== LIST ALL APPS =="
begin
response = app.list_all
pp response.parsed_response
rescue => e
puts "[Error listing apps] \#{e.message}"
end
API > Team
require "discloud"
client = Discloud::Client.new(token: "API-TOKEN")
team = Discloud::Resources::Team.new(client)
app_id = "YOUR_APP_ID"
mod_id = "MOD_USER_ID"
puts "== TEAM INFO =="
begin
response = team.info(app_id)
pp response.parsed_response
rescue => e
puts "[Error getting team info] \#{e.message}"
end
puts "\n== ADDING MEMBER =="
begin
response = team.add_member(app_id, mod_id, ["start_app", "stop_app"])
pp response.parsed_response
rescue => e
puts "[Add member failed] \#{e.message}"
end
puts "\n== EDITING MEMBER PERMISSIONS =="
begin
response = team.edit_member(app_id, mod_id, [
"backup_app",
"commit_app",
"edit_ram",
"logs_app",
"restart_app",
"start_app",
"status_app",
"stop_app",
])
pp response.parsed_response
rescue => e
puts "[Edit member failed] \#{e.message}"
end
puts "\n== REMOVING MEMBER =="
begin
response = team.remove_member(app_id, mod_id)
pp response.parsed_response
rescue => e
puts "[Remove member failed] \#{e.message}"
end