Class: Circonus::Client

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

Constant Summary collapse

API_URL =
'https://api.circonus.com/v2'

Instance Method Summary collapse

Constructor Details

#initialize(app_name, auth_token) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/circonus/client.rb', line 5

def initialize(app_name, auth_token)
  headers = { x_circonus_app_name: app_name, x_circonus_auth_token: auth_token, content_type: :json, accept: :json }
  @resource = RestClient::Resource.new(API_URL, headers: headers)
end

Instance Method Details

#delete(path) ⇒ Object



22
23
24
# File 'lib/circonus/client.rb', line 22

def delete(path)
  with_rescue { @resource[path].delete }
end

#get(path, params = {}) ⇒ Object



10
11
12
# File 'lib/circonus/client.rb', line 10

def get(path, params = {})
  with_rescue { @resource[path].get(params: params) }
end

#post(path, data) ⇒ Object



14
15
16
# File 'lib/circonus/client.rb', line 14

def post(path, data)
  with_rescue { @resource[path].post(data.to_json) }
end

#put(path, data) ⇒ Object



18
19
20
# File 'lib/circonus/client.rb', line 18

def put(path, data)
  with_rescue { @resource[path].put(data.to_json) }
end