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(connection) ⇒ Tasks
constructor
A new instance of Tasks.
-
#list(status = nil) ⇒ Object
List tasks of all applications.
Constructor Details
#initialize(connection) ⇒ Tasks
Returns a new instance of Tasks.
78 79 80 |
# File 'lib/marathon/task.rb', line 78 def initialize(connection) @connection = 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.
103 104 105 106 107 108 |
# File 'lib/marathon/task.rb', line 103 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.
115 116 117 118 119 120 121 |
# File 'lib/marathon/task.rb', line 115 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) } end |
#get(appId) ⇒ Object
List all running tasks for application appId. appId
: Application’s id
94 95 96 97 |
# File 'lib/marathon/task.rb', line 94 def get(appId) json = @connection.get("/v2/apps/#{appId}/tasks")['tasks'] json.map { |j| Marathon::Task.new(j) } 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.
85 86 87 88 89 90 |
# File 'lib/marathon/task.rb', line 85 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) } end |