Class: CloudQuartz

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/cloud-quartz.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CloudQuartz

Returns a new instance of CloudQuartz.



9
10
11
12
13
14
# File 'lib/cloud-quartz.rb', line 9

def initialize(options = {})
	@api_key = options[:api_key]
	@agent_id = options[:agent_id]
	@secret_key = options[:secret_key]
	self.class.base_uri options[:url] || 'https://api.cloudblocks.co'
end

Instance Method Details

#get_jobObject



16
17
18
# File 'lib/cloud-quartz.rb', line 16

def get_job
	process(self.class.get("/queue/#{@agent_id}.json", { :headers => ClientAuth.build_headers(@api_key, @secret_key) } ))
end

#init(version, plugins) ⇒ Object



46
47
48
49
# File 'lib/cloud-quartz.rb', line 46

def init(version, plugins)
	data = { :version => version, :plugins => plugins }
	process(self.class.post("/agent/#{@agent_id}/initialize.json", { :headers => ClientAuth.build_headers(@api_key, @secret_key).merge({'Content-Type' => 'application/json'}), :body => data.to_json }))
end

#post_results(job_id, data) ⇒ Object

TODO: Is this deprecated now? def check_version self.class.get(“/agent/version”, :headers => ClientAuth.build_headers(@api_key, @secret_key)) end



33
34
35
# File 'lib/cloud-quartz.rb', line 33

def post_results(job_id, data)
	process(self.class.post("/job/#{job_id}/complete.json", { :headers => ClientAuth.build_headers(@api_key, @secret_key).merge({'Content-Type' => 'application/json'}), :body => data.to_json } ))
end

#pulseObject



37
38
39
# File 'lib/cloud-quartz.rb', line 37

def pulse
	process(self.class.get("/agent/#{@agent_id}/pulse.json", { :headers => ClientAuth.build_headers(@api_key, @secret_key) } ))
end

#register(agent) ⇒ Object



20
21
22
# File 'lib/cloud-quartz.rb', line 20

def register(agent)
	process(self.class.post('/agent.json', { :headers => ClientAuth.build_headers(@api_key, @secret_key).merge({'Content-Type' => 'application/json'}), :body => agent.to_json }))
end

#status(stat) ⇒ Object



41
42
43
44
# File 'lib/cloud-quartz.rb', line 41

def status(stat)
	data = { :status => stat }
	process(self.class.post("/agent/#{@agent_id}/status.json", { :headers => ClientAuth.build_headers(@api_key, @secret_key).merge({'Content-Type' => 'application/json'}), :body => data.to_json }))
end

#unregister(agent) ⇒ Object



24
25
26
# File 'lib/cloud-quartz.rb', line 24

def unregister(agent)
	process(self.class.delete("/agent/#{@agent_id}.json", :headers => ClientAuth.build_headers(@api_key, @secret_key)))
end