Class: Marathon::Apps
- Inherits:
-
Object
- Object
- Marathon::Apps
- Defined in:
- lib/marathon/app.rb
Overview
This class represents a set of Apps
Instance Method Summary collapse
-
#change(id, hash, force = false) ⇒ Object
Change parameters of a running application.
-
#delete(id) ⇒ Object
Delete the application with id.
-
#get(id) ⇒ Object
List the application with id.
-
#initialize(marathon_instance) ⇒ Apps
constructor
A new instance of Apps.
-
#list(cmd = nil, embed = nil, id = nil, label = nil) ⇒ Object
List all applications.
-
#restart(id, force = false) ⇒ Object
Restart the application with id.
-
#start(hash) ⇒ Object
Create and start an application.
-
#version(id, version) ⇒ Object
List the configuration of the application with id at version.
-
#versions(id) ⇒ Object
List the versions of the application with id.
Constructor Details
#initialize(marathon_instance) ⇒ Apps
Returns a new instance of Apps.
241 242 243 244 |
# File 'lib/marathon/app.rb', line 241 def initialize(marathon_instance) @marathon_instance = marathon_instance @connection = marathon_instance.connection end |
Instance Method Details
#change(id, hash, force = false) ⇒ Object
Change parameters of a running application. The new application parameters apply only to subsequently created tasks. Currently running tasks are restarted, while maintaining the minimumHealthCapacity. id
: Application’s id. hash
: A subset of app’s attributes. force
: If the app is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
285 286 287 288 289 290 |
# File 'lib/marathon/app.rb', line 285 def change(id, hash, force = false) query = {} query[:force] = true if force json = @connection.put("/v2/apps/#{id}", query, :body => hash.merge(:id => id)) Marathon::DeploymentInfo.new(json, @marathon_instance) end |
#delete(id) ⇒ Object
Delete the application with id. id
: Application’s id.
255 256 257 258 |
# File 'lib/marathon/app.rb', line 255 def delete(id) json = @connection.delete("/v2/apps/#{id}") Marathon::DeploymentInfo.new(json, @marathon_instance) end |
#get(id) ⇒ Object
List the application with id. id
: Application’s id.
248 249 250 251 |
# File 'lib/marathon/app.rb', line 248 def get(id) json = @connection.get("/v2/apps/#{id}")['app'] Marathon::App.new(json, @marathon_instance) end |
#list(cmd = nil, embed = nil, id = nil, label = nil) ⇒ Object
List all applications. :cmd
: Filter apps to only those whose commands contain cmd. :embed
: Embeds nested resources that match the supplied path.
Possible values:
"apps.tasks". Apps' tasks are not embedded in the response by default.
"apps.counts". Apps' task counts (tasksStaged, tasksRunning, tasksHealthy, tasksUnhealthy).
"apps.deployments". Apps' embed all deployment identifier.
"apps.lastTaskFailure". Apps' embeds the lastTaskFailure
"apps.failures". Apps' last failures are not embedded in the response by default.
"apps.taskStats". Apps' exposes task statatistics.
:id
: Filter apps to only return those whose id is or contains id. :label
: A label selector query contains one or more label selectors
319 320 321 322 323 324 325 326 327 328 |
# File 'lib/marathon/app.rb', line 319 def list(cmd = nil, = nil, id=nil, label=nil) query = {} query[:cmd] = cmd if cmd query[:id] = id if id query[:label] = label if label Marathon::Util.add_choice(query, :embed, , %w[apps.tasks apps.counts apps.deployments apps.lastTaskFailure apps.failures apps.taskStats ]) json = @connection.get('/v2/apps', query)['apps'] json.map { |j| Marathon::App.new(j, @marathon_instance) } end |
#restart(id, force = false) ⇒ Object
Restart the application with id. id
: Application’s id. force
: If the app is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
272 273 274 275 276 277 |
# File 'lib/marathon/app.rb', line 272 def restart(id, force = false) query = {} query[:force] = true if force json = @connection.post("/v2/apps/#{id}/restart", query) Marathon::DeploymentInfo.new(json, @marathon_instance) end |
#start(hash) ⇒ Object
Create and start an application. hash
: Hash including all attributes
see https://mesosphere.github.io/marathon/docs/rest-api.html#post-/v2/apps for full details
263 264 265 266 |
# File 'lib/marathon/app.rb', line 263 def start(hash) json = @connection.post('/v2/apps', nil, :body => hash) Marathon::App.new(json, @marathon_instance) end |
#version(id, version) ⇒ Object
List the configuration of the application with id at version. id
: Application id version
: Version name
302 303 304 305 |
# File 'lib/marathon/app.rb', line 302 def version(id, version) json = @connection.get("/v2/apps/#{id}/versions/#{version}") Marathon::App.new(json, @marathon_instance, true) end |
#versions(id) ⇒ Object
List the versions of the application with id. id
: Application id
294 295 296 297 |
# File 'lib/marathon/app.rb', line 294 def versions(id) json = @connection.get("/v2/apps/#{id}/versions") json['versions'] end |