Class: Blitz::Client
- Inherits:
-
Object
- Object
- Blitz::Client
- Defined in:
- lib/blitz/client.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#blitz ⇒ Object
readonly
Returns the value of attribute blitz.
Instance Method Summary collapse
- #abort_job(job_id) ⇒ Object
- #account_about ⇒ Object
- #curl_execute(data) ⇒ Object
-
#initialize(user, apik, host = 'blitz.io') ⇒ Client
constructor
A new instance of Client.
- #job_status(job_id) ⇒ Object
- #login ⇒ Object
- #traceroute_execute(data) ⇒ Object
Constructor Details
#initialize(user, apik, host = 'blitz.io') ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 |
# File 'lib/blitz/client.rb', line 7 def initialize user, apik, host='blitz.io' scheme = host.index('localhost') ? 'http' : 'https' @blitz = RestClient::Resource.new "#{scheme}://#{host}", \ :headers => { :x_api_user => user, :x_api_key => apik, :x_api_client => 'gem' } end |
Instance Attribute Details
#blitz ⇒ Object (readonly)
Returns the value of attribute blitz.
5 6 7 |
# File 'lib/blitz/client.rb', line 5 def blitz @blitz end |
Instance Method Details
#abort_job(job_id) ⇒ Object
37 38 39 |
# File 'lib/blitz/client.rb', line 37 def abort_job job_id JSON.parse blitz["/api/1/jobs/#{job_id}/abort"].put '' end |
#account_about ⇒ Object
21 22 23 |
# File 'lib/blitz/client.rb', line 21 def account_about JSON.parse blitz['/api/1/account/about'].get end |
#curl_execute(data) ⇒ Object
25 26 27 |
# File 'lib/blitz/client.rb', line 25 def curl_execute data JSON.parse blitz['/api/1/curl/execute'].post(data.to_json) end |
#job_status(job_id) ⇒ Object
33 34 35 |
# File 'lib/blitz/client.rb', line 33 def job_status job_id JSON.parse blitz["/api/1/jobs/#{job_id}/status"].get end |
#login ⇒ Object
17 18 19 |
# File 'lib/blitz/client.rb', line 17 def login JSON.parse blitz['/login/api'].get end |
#traceroute_execute(data) ⇒ Object
29 30 31 |
# File 'lib/blitz/client.rb', line 29 def traceroute_execute data JSON.parse blitz['/api/1/traceroute/execute'].post(data.to_json) end |