Class: Marathon::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/marathon/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = nil, user = nil, pass = nil) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
18
# File 'lib/marathon/client.rb', line 11

def initialize(host = nil, user = nil, pass = nil)
  @host = host || ENV['MARATHON_HOST'] || 'http://localhost:8080'
  @default_options = {}

  if user && pass
    @default_options[:basic_auth] = {:username => user, :password => pass}
  end
end

Instance Method Details

#listObject



20
21
22
# File 'lib/marathon/client.rb', line 20

def list
  wrap_request(:get, '/v1/apps')
end

#scale(id, num_instances) ⇒ Object



30
31
32
33
# File 'lib/marathon/client.rb', line 30

def scale(id, num_instances)
  body = {:id => id, :instances => num_instances}
  wrap_request(:post, '/v1/apps/scale', :body => body)
end

#start(id, opts) ⇒ Object



24
25
26
27
28
# File 'lib/marathon/client.rb', line 24

def start(id, opts)
  body = opts.dup
  body[:id] = id
  wrap_request(:post, '/v1/apps/start', :body => body)
end

#stop(id) ⇒ Object



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

def stop(id)
  body = {:id => id}
  wrap_request(:post, '/v1/apps/stop', :body => body)
end