class Lita::Handlers::Marathon

Public Instance Methods

change_apps(response) click to toggle source
# File lib/lita/handlers/marathon.rb, line 47
def change_apps response
  force, command, filter, instances = response.matches.flatten
  list = ::Marathon::App.list(nil, nil, filter)
  response.reply t("response.no_apps") if list.empty?
  list.each do |app|
    begin
      case command
        when "restart"
          app.restart!(force)
        when "suspend"
          app.suspend!(force)
        when "scale"
          app.scale!(instances.to_i, force)
        else
      end
      response.reply render_template("change_app", command: command, app: app.id, instances: instances)
    rescue ::Marathon::Error::UnexpectedResponseError => e
      response.reply t("error.unexpected_response", app: app.id)
    end
  end
end
count_apps(response) click to toggle source
# File lib/lita/handlers/marathon.rb, line 41
def count_apps response
  filter = response.matches.flatten.first
  apps = ::Marathon::App.list(nil, "apps.taskStats", filter)
  response.reply render_template("count_apps", apps: apps)
end
list_apps(response) click to toggle source
# File lib/lita/handlers/marathon.rb, line 35
def list_apps response
  filter = response.matches.flatten.first
  apps = ::Marathon::App.list(nil, nil, filter)
  response.reply render_template("list_apps", apps: apps)
end