class Marathon::Tasks

This class represents a set of Tasks

Public Class Methods

new(marathon_instance) click to toggle source
# File lib/marathon/task.rb, line 83
def initialize(marathon_instance)
  @marathon_instance = marathon_instance
  @connection = marathon_instance.connection
end

Public Instance Methods

delete(ids, scale = false) click to toggle source

Kill the given list of tasks and scale apps if requested. ids: Id or list of ids with target tasks. scale: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)

after killing the specified tasks.
# File lib/marathon/task.rb, line 109
def delete(ids, scale = false)
  query = {}
  query[:scale] = true if scale
  ids = [ids] if ids.is_a?(String)
  @connection.post("/v2/tasks/delete", query, :body => {:ids => ids})
end
delete_all(appId, host = nil, scale = false) click to toggle source

Kill tasks that belong to the application appId. appId: Application's id host: Kill only those tasks running on host host. scale: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)

after killing the specified tasks.
# File lib/marathon/task.rb, line 121
def delete_all(appId, host = nil, scale = false)
  query = {}
  query[:host] = host if host
  query[:scale] = true if scale
  json = @connection.delete("/v2/apps/#{appId}/tasks", query)['tasks']
  json.map { |j| Marathon::Task.new(j, @marathon_instance) }
end
get(appId) click to toggle source

List all running tasks for application appId. appId: Application's id

# File lib/marathon/task.rb, line 100
def get(appId)
  json = @connection.get("/v2/apps/#{appId}/tasks")['tasks']
  json.map { |j| Marathon::Task.new(j, @marathon_instance) }
end
list(status = nil) click to toggle source

List tasks of all applications. status: Return only those tasks whose status matches this parameter.

If not specified, all tasks are returned. Possible values: running, staging.
# File lib/marathon/task.rb, line 91
def list(status = nil)
  query = {}
  Marathon::Util.add_choice(query, :status, status, %w[running staging])
  json = @connection.get('/v2/tasks', query)['tasks']
  json.map { |j| Marathon::Task.new(j, @marathon_instance) }
end