Class: Marathon::Deployment

Inherits:
Base
  • Object
show all
Defined in:
lib/marathon/deployment.rb

Overview

This class represents a Marathon Deployment. See mesosphere.github.io/marathon/docs/rest-api.html#deployments for full list of API’s methods.

Constant Summary collapse

ACCESSORS =
%w[ id affectedApps version currentStep totalSteps ]

Instance Attribute Summary collapse

Attributes inherited from Base

#info

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_json

Methods included from Error

error_class, error_message, from_response

Constructor Details

#initialize(hash) ⇒ Deployment

Create a new deployment object. hash: Hash including all attributes.

See https://mesosphere.github.io/marathon/docs/rest-api.html#get-/v2/deployments for full details.


11
12
13
14
15
# File 'lib/marathon/deployment.rb', line 11

def initialize(hash)
  super(hash, ACCESSORS)
  @currentActions = (info[:currentActions] || []).map { |e| Marathon::DeploymentAction.new(e) }
  @steps = (info[:steps] || []).map { |e| Marathon::DeploymentStep.new(e) }
end

Instance Attribute Details

#currentActionsObject (readonly)

Returns the value of attribute currentActions.



6
7
8
# File 'lib/marathon/deployment.rb', line 6

def currentActions
  @currentActions
end

#stepsObject (readonly)

Returns the value of attribute steps.



6
7
8
# File 'lib/marathon/deployment.rb', line 6

def steps
  @steps
end

Class Method Details

.delete(id, force = false) ⇒ Object Also known as: cancel, remove

Cancel the deployment with id. id: Deployment’s id force: If set to false (the default) then the deployment is canceled and a new deployment

is created to restore the previous configuration. If set to true, then the deployment
is still canceled but no rollback deployment is created.


44
45
46
47
48
49
# File 'lib/marathon/deployment.rb', line 44

def delete(id, force = false)
  query = {}
  query[:force] = true if force
  json = Marathon.connection.delete("/v2/deployments/#{id}")
  Marathon::DeploymentInfo.new(json)
end

.listObject

List running deployments.



34
35
36
37
# File 'lib/marathon/deployment.rb', line 34

def list
  json = Marathon.connection.get('/v2/deployments')
  json.map { |j| new(j) }
end

Instance Method Details

#cancelObject

Cancel the deployment. force: If set to false (the default) then the deployment is canceled and a new deployment

is created to restore the previous configuration. If set to true, then the deployment
is still canceled but no rollback deployment is created.


24
25
26
# File 'lib/marathon/deployment.rb', line 24

def delete(force = false)
  self.class.delete(id, force)
end

#delete(force = false) ⇒ Object

Cancel the deployment. force: If set to false (the default) then the deployment is canceled and a new deployment

is created to restore the previous configuration. If set to true, then the deployment
is still canceled but no rollback deployment is created.


21
22
23
# File 'lib/marathon/deployment.rb', line 21

def delete(force = false)
  self.class.delete(id, force)
end

#to_sObject



26
27
28
29
# File 'lib/marathon/deployment.rb', line 26

def to_s
  "Marathon::Deployment { " \
    + ":id => #{id} :affectedApps => #{affectedApps} :currentStep => #{currentStep} :totalSteps => #{totalSteps} }"
end