Class: Jenkins2::API::Computer::Proxy

Inherits:
ResourceProxy show all
Includes:
RUD
Defined in:
lib/jenkins2/api/computer.rb

Instance Attribute Summary collapse

Attributes inherited from ResourceProxy

#connection, #path

Instance Method Summary collapse

Methods included from RUD

#config_xml, #delete, #update

Methods inherited from ResourceProxy

#initialize, #method_missing, #raw, #respond_to_missing?, #subject

Constructor Details

This class inherits a constructor from Jenkins2::ResourceProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jenkins2::ResourceProxy

Instance Attribute Details

#idObject

Returns the value of attribute id.



17
18
19
# File 'lib/jenkins2/api/computer.rb', line 17

def id
  @id
end

Instance Method Details

#createObject



24
25
26
27
28
29
# File 'lib/jenkins2/api/computer.rb', line 24

def create
	form_data = { name: @id, type: 'hudson.slaves.DumbSlave$DescriptorImpl', json: '{}' }
	@id = nil
	path = build_path 'doCreateItem'
	connection.post(path, ::URI.encode_www_form(form_data)).code == '302'
end

#disconnect(offline_message = nil) ⇒ Object



31
32
33
34
35
# File 'lib/jenkins2/api/computer.rb', line 31

def disconnect(offline_message=nil)
	path = build_path 'doDisconnect'
	body = "offlineMessage=#{::CGI.escape offline_message}" unless offline_message.nil?
	connection.post(path, body).code == '302'
end

#launch_agentObject



20
21
22
# File 'lib/jenkins2/api/computer.rb', line 20

def launch_agent
	connection.post(build_path('launchSlaveAgent')).code == '302'
end

#online?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/jenkins2/api/computer.rb', line 43

def online?
	not ( offline or temporarilyOffline)
end

#toggle_offline(offline_message = nil) ⇒ Object



37
38
39
40
41
# File 'lib/jenkins2/api/computer.rb', line 37

def toggle_offline(offline_message=nil)
	path = build_path 'toggleOffline'
	body = "offlineMessage=#{::CGI.escape offline_message}" unless offline_message.nil?
	connection.post(path, body).code == '302'
end