Class: Bamboo::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bamboo/client.rb

Defined Under Namespace

Classes: InvalidResponseError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
# File 'lib/bamboo/client.rb', line 7

def initialize(host)
  @host = host
  @uri = URI(host)

  @http = Net::HTTP.new(@uri.host, @uri.port)
  @http.use_ssl = @uri.is_a?(URI::HTTPS)
  @http.start # for keep-alive
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/bamboo/client.rb', line 5

def host
  @host
end

Instance Method Details

#appsObject



34
35
36
# File 'lib/bamboo/client.rb', line 34

def apps
  state.fetch('Apps')
end

#create_service(id, definition) ⇒ Object



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

def create_service(id, definition)
  post('/api/services', { 'Id' => id }.merge(definition))
end

#delete_service(id) ⇒ Object



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

def delete_service(id)
  delete(service_path(id))
  true
end

#get_service(id) ⇒ Object



29
30
31
# File 'lib/bamboo/client.rb', line 29

def get_service(id)
  state.fetch('Services')[id]
end

#servicesObject



39
40
41
# File 'lib/bamboo/client.rb', line 39

def services
  state.fetch('Services').values
end

#stateObject



43
44
45
# File 'lib/bamboo/client.rb', line 43

def state
  get('/api/state')
end

#update_service(id, definition) ⇒ Object



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

def update_service(id, definition)
  put(service_path(id), { 'Id' => id }.merge(definition))
end