class ChawkRemote::Addr
Attributes
api_key[RW]
client_id[RW]
host[RW]
series_key[RW]
Public Class Methods
new(host, series_key, client_id, api_key)
click to toggle source
# File lib/chawk_remote.rb, line 9 def initialize(host, series_key, client_id, api_key) @host = host @client_id = client_id @api_key = api_key @series_key = series_key #puts "#{@host} - #{@client_id} - #{@api_key} #{series_key}" end
Public Instance Methods
add_points(points)
click to toggle source
# File lib/chawk_remote.rb, line 23 def add_points(points) r = HTTParty.post "#{@host}/api/v1/nodes/#{@series_key}/add_points", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""}, :body => {"payload" => "{\"data\":[#{points.join(',')}]}", :meta => "{\"source\":\"chawk_remote\"}"} end
clear()
click to toggle source
# File lib/chawk_remote.rb, line 19 def clear r = HTTParty.put "#{@host}/api/v1/nodes/#{@series_key}/clear", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end
decrement(count)
click to toggle source
# File lib/chawk_remote.rb, line 35 def decrement(count) r = HTTParty.put "#{@host}/api/v1/nodes/#{@series_key}/decrement", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""}, :body => {"payload" => "{\"data\":#{count}}", :meta => "{\"source\":\"chawk_remote\"}"} end
increment(count)
click to toggle source
# File lib/chawk_remote.rb, line 29 def increment(count) r = HTTParty.put "#{@host}/api/v1/nodes/#{@series_key}/increment", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""}, :body => {"payload" => "{\"data\":#{count}}", :meta => "{\"source\":\"chawk_remote\"}"} end
last(length)
click to toggle source
# File lib/chawk_remote.rb, line 41 def last(length) r = HTTParty.get "#{@host}/api/v1/nodes/#{@series_key}/last", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end
range(from, to)
click to toggle source
# File lib/chawk_remote.rb, line 46 def range(from, to) r = HTTParty.get "#{@host}/api/v1/nodes/#{@series_key}/range?from=#{from}&to=#{to}", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end
since(from)
click to toggle source
# File lib/chawk_remote.rb, line 51 def since (from) r = HTTParty.get "#{@host}/api/v1/nodes/#{@series_key}/since?from=#{from}", :headers=>{"Authorization"=>"Token token=\"#{@client_id}/#{@api_key}\""} end