Class: Mu::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mu/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#muObject (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

#loginObject



19
20
21
# File 'lib/mu/client.rb', line 19

def 
    JSON.parse mu['/account/login/api'].get
end