Class: Marathon::Tasks
- Inherits:
-
Object
- Object
- Marathon::Tasks
- Defined in:
- lib/marathon/task.rb
Overview
This class represents a set of Tasks
Instance Method Summary collapse
-
#delete(ids, scale = false) ⇒ Object
Kill the given list of tasks and scale apps if requested.
-
#delete_all(appId, host = nil, scale = false) ⇒ Object
Kill tasks that belong to the application appId.
-
#get(appId) ⇒ Object
List all running tasks for application appId.
-
#initialize(marathon_instance) ⇒ Tasks
constructor
A new instance of Tasks.
-
#list(status = nil) ⇒ Object
List tasks of all applications.
Constructor Details
#initialize(marathon_instance) ⇒ Tasks
Returns a new instance of Tasks.
83 84 85 86 |
# File 'lib/marathon/task.rb', line 83 def initialize(marathon_instance) @marathon_instance = marathon_instance @connection = marathon_instance.connection end |
Instance Method Details
#delete(ids, scale = false) ⇒ Object
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.
109 110 111 112 113 114 |
# 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) ⇒ Object
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.
121 122 123 124 125 126 127 |
# 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) ⇒ Object
List all running tasks for application appId. appId
: Application’s id
100 101 102 103 |
# 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) ⇒ Object
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.
91 92 93 94 95 96 |
# 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 |