class Loggly
Public Class Methods
new(options)
click to toggle source
# File lib/ruby_loggly.rb, line 5 def initialize(options) @subdomain = options[:subdomain] @user = options[:user] @pass = options[:pass] @key = options[:key] @ec2 = options[:ec2] ||= false end
Public Instance Methods
add_device(options)
click to toggle source
# File lib/ruby_loggly.rb, line 49 def add_device(options) response = RestClient.post("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/",:ip=>options[:ip],:input_id=>options[:input_id]) response.code==201 ? true : false end
add_input(options)
click to toggle source
# File lib/ruby_loggly.rb, line 35 def add_input(options) response = RestClient.post("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/", :name=>options[:name],:description=> options[:description],:service=>options[:service]) response.code==201 ? true : false end
get_device(options) { |device_hash| ... }
click to toggle source
# File lib/ruby_loggly.rb, line 57 def get_device(options) response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/#{options[:id]}") device=nil device_hash=JSON.parse(response.to_str) yield device_hash if block_given? device_hash end
get_input(options) { |input_hash| ... }
click to toggle source
# File lib/ruby_loggly.rb, line 29 def get_input(options) response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/#{options[:id]}") input_hash=JSON.parse(response.to_str) yield input_hash if block_given? input_hash end
list_devices() { |response_array| ... }
click to toggle source
# File lib/ruby_loggly.rb, line 43 def list_devices response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/") response_array=JSON.parse(response.to_str) yield response_array if block_given? response_array end
list_inputs() { |response_array| ... }
click to toggle source
# File lib/ruby_loggly.rb, line 23 def list_inputs response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/") response_array=JSON.parse(response.to_str) yield response_array if block_given? response_array end
log(log_data)
click to toggle source
# File lib/ruby_loggly.rb, line 13 def log(log_data) ec2flag = @ec2 ? 'ec2.' : '' RestClient.post("https://#{ec2flag}logs.loggly.com/inputs/#{@key}", log_data) end
remove_device(options)
click to toggle source
# File lib/ruby_loggly.rb, line 53 def remove_device(options) response = RestClient.delete("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/#{options[:id]}") response.code==204 ? true : false end
remove_input(options)
click to toggle source
# File lib/ruby_loggly.rb, line 39 def remove_input(options) response = RestClient.delete("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/#{options[:id]}") response.code==204 ? true : false end
search(query) { |to_str| ... }
click to toggle source
# File lib/ruby_loggly.rb, line 18 def search(query) response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/search", {:params => {:q => query}}) yield response.to_str if block_given? end