Class: Bamboo::Client::Rest

Inherits:
Abstract show all
Defined in:
lib/bamboo-client/rest.rb

Overview

Defined Under Namespace

Classes: Change, Plan, Project, Queue, QueuedBuild, Result

Constant Summary collapse

SERVICE =
"/rest/api/latest"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Rest

Returns a new instance of Rest.



16
17
18
19
# File 'lib/bamboo-client/rest.rb', line 16

def initialize(http)
  super
  @cookies = nil
end

Instance Attribute Details

#cookiesObject (readonly)

Returns the value of attribute cookies.



12
13
14
# File 'lib/bamboo-client/rest.rb', line 12

def cookies
  @cookies
end

Instance Method Details

#login(username, password) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/bamboo-client/rest.rb', line 21

def (username, password)
  url = File.join(SERVICE, 'plan')
  resp = @http.get_cookies(url, {
                                  :os_authType => 'basic',
                                  :os_username => username,
                                  :os_password => password
                                  }
                            )
  @cookies = {:JSESSIONID => resp['JSESSIONID']}
end

#plan_for(key) ⇒ Object



52
53
54
# File 'lib/bamboo-client/rest.rb', line 52

def plan_for(key)
  Plan.new get("plan/#{URI.escape key}").data, @http
end

#plansObject



32
33
34
# File 'lib/bamboo-client/rest.rb', line 32

def plans
  get("plan/").auto_expand Plan, @http
end

#project_for(key) ⇒ Object



40
41
42
# File 'lib/bamboo-client/rest.rb', line 40

def project_for(key)
  Project.new get("project/#{URI.escape key}").data, @http
end

#projectsObject



36
37
38
# File 'lib/bamboo-client/rest.rb', line 36

def projects
  get("project/").auto_expand Project, @http
end

#queueObject



56
57
58
# File 'lib/bamboo-client/rest.rb', line 56

def queue
  Queue.new get("queue/").data, @http
end

#resultsObject



44
45
46
# File 'lib/bamboo-client/rest.rb', line 44

def results
  get("result/").auto_expand Result, @http
end

#results_for(key) ⇒ Object



48
49
50
# File 'lib/bamboo-client/rest.rb', line 48

def results_for(key)
  get("result/#{URI.escape key}").auto_expand Result, @http
end