class ProxyAPI::Openbolt
Public Class Methods
new(args)
click to toggle source
Calls superclass method
# File lib/proxy_api/openbolt.rb, line 7 def initialize(args) @url = args[:url] super end
Public Instance Methods
delete_job_artifacts(job_id:)
click to toggle source
# File lib/proxy_api/openbolt.rb, line 50 def delete_job_artifacts(job_id:) parse_response(delete("/openbolt/job/#{job_id}/artifacts"), 'delete_job_artifacts') end
fetch_tasks()
click to toggle source
# File lib/proxy_api/openbolt.rb, line 12 def fetch_tasks @tasks = parse_response(get('/openbolt/tasks'), 'fetch_tasks') end
job_result(job_id:)
click to toggle source
# File lib/proxy_api/openbolt.rb, line 46 def job_result(job_id:) parse_response(get("/openbolt/job/#{job_id}/result"), 'job_result') end
job_status(job_id:)
click to toggle source
# File lib/proxy_api/openbolt.rb, line 42 def job_status(job_id:) parse_response(get("/openbolt/job/#{job_id}/status"), 'job_status') end
launch_task(name:, targets:, parameters: {}, options: {})
click to toggle source
# File lib/proxy_api/openbolt.rb, line 32 def launch_task(name:, targets:, parameters: {}, options: {}) response = post({ name: name, targets: targets, parameters: parameters, options: options, }.to_json, '/openbolt/launch/task') parse_response(response, 'launch_task') end
openbolt_options()
click to toggle source
# File lib/proxy_api/openbolt.rb, line 28 def openbolt_options @openbolt_options ||= parse_response(get('/openbolt/tasks/options'), 'openbolt_options') end
parse_response(response, operation)
click to toggle source
# File lib/proxy_api/openbolt.rb, line 54 def parse_response(response, operation) unless response raise ProxyException.new( @url, RuntimeError.new("No response from Smart Proxy during #{operation}"), "No response from Smart Proxy during #{operation}" ) end body = response.body if body.nil? raise ProxyException.new( @url, RuntimeError.new("Empty response body from Smart Proxy during #{operation}"), "Empty response body from Smart Proxy during #{operation}" ) end JSON.parse(body) rescue JSON::ParserError => e raise ProxyException.new( @url, e, "Invalid JSON from Smart Proxy during #{operation}: #{e.message}. " \ "Response body (first 500 chars): #{body.to_s[0..500]}" ) end
reload_tasks()
click to toggle source
# File lib/proxy_api/openbolt.rb, line 20 def reload_tasks @tasks = parse_response(get('/openbolt/tasks/reload'), 'reload_tasks') end
task_names()
click to toggle source
# File lib/proxy_api/openbolt.rb, line 24 def task_names tasks.keys end
tasks()
click to toggle source
# File lib/proxy_api/openbolt.rb, line 16 def tasks @tasks ||= fetch_tasks end