Class: Mu::Client
- Inherits:
-
Object
- Object
- Mu::Client
- Defined in:
- lib/mu/client.rb
Instance Attribute Summary collapse
-
#mu ⇒ Object
readonly
Returns the value of attribute mu.
Instance Method Summary collapse
- #abort_job(job_id) ⇒ Object
- #curl(data) ⇒ Object
-
#initialize(user, apik, host = '') ⇒ Client
constructor
A new instance of Client.
- #job_status(job_id) ⇒ Object
- #login ⇒ Object
Constructor Details
#initialize(user, apik, host = '') ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 |
# File 'lib/mu/client.rb', line 5 def initialize user, apik, host='' scheme = host.index('localhost') ? 'http' : 'https' @mu = RestClient::Resource.new "#{scheme}://#{host}", \ :headers => { :x_api_user => user, :x_api_key => apik, :x_api_version => ::Mu::Version } end |
Instance Attribute Details
#mu ⇒ Object (readonly)
Returns the value of attribute mu.
3 4 5 |
# File 'lib/mu/client.rb', line 3 def mu @mu end |
Instance Method Details
#abort_job(job_id) ⇒ Object
27 28 29 |
# File 'lib/mu/client.rb', line 27 def abort_job job_id JSON.parse mu["/api/1/jobs/#{job_id}/abort"].put('') end |
#curl(data) ⇒ Object
15 16 17 |
# File 'lib/mu/client.rb', line 15 def curl data JSON.parse mu['/api/1/curl'].post(data.to_json) end |
#job_status(job_id) ⇒ Object
23 24 25 |
# File 'lib/mu/client.rb', line 23 def job_status job_id JSON.parse mu["/api/1/jobs/#{job_id}/status"].get end |
#login ⇒ Object
19 20 21 |
# File 'lib/mu/client.rb', line 19 def login JSON.parse mu['/account/login/api'].get end |