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, marathon_instance) ⇒ 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
16
# File 'lib/marathon/deployment.rb', line 11

def initialize(hash, marathon_instance)
  super(hash, ACCESSORS)
  @marathon_instance = marathon_instance
  @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.


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

def delete(id, force = false)
  Marathon.singleton.deployments.delete(id, force)
end

.listObject

List running deployments.



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

def list
  Marathon.singleton.deployments.list
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.


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

def delete(force = false)
  @marathon_instance.deployments.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.


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

def delete(force = false)
  @marathon_instance.deployments.delete(id, force)
end

#to_sObject



28
29
30
31
# File 'lib/marathon/deployment.rb', line 28

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