Class: Loggly
- Inherits:
-
Object
- Object
- Loggly
- Defined in:
- lib/ruby_loggly.rb
Instance Method Summary collapse
- #add_device(options) ⇒ Object
- #add_input(options) ⇒ Object
- #get_device(options) {|device_hash| ... } ⇒ Object
- #get_input(options) {|input_hash| ... } ⇒ Object
-
#initialize(options) ⇒ Loggly
constructor
A new instance of Loggly.
- #list_devices {|response_array| ... } ⇒ Object
- #list_inputs {|response_array| ... } ⇒ Object
- #log(log_data) ⇒ Object
- #remove_device(options) ⇒ Object
- #remove_input(options) ⇒ Object
- #search(query) {|response.to_str| ... } ⇒ Object
Constructor Details
#initialize(options) ⇒ Loggly
Returns a new instance of Loggly.
5 6 7 8 9 10 11 |
# File 'lib/ruby_loggly.rb', line 5 def initialize() @subdomain = [:subdomain] @user = [:user] @pass = [:pass] @key = [:key] @ec2 = [:ec2] ||= false end |
Instance Method Details
#add_device(options) ⇒ Object
49 50 51 52 |
# File 'lib/ruby_loggly.rb', line 49 def add_device() response = RestClient.post("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/",:ip=>[:ip],:input_id=>[:input_id]) response.code==201 ? true : false end |
#add_input(options) ⇒ Object
35 36 37 38 |
# File 'lib/ruby_loggly.rb', line 35 def add_input() response = RestClient.post("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/", :name=>[:name],:description=> [:description],:service=>[:service]) response.code==201 ? true : false end |
#get_device(options) {|device_hash| ... } ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/ruby_loggly.rb', line 57 def get_device() response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/#{[:id]}") device=nil device_hash=JSON.parse(response.to_str) yield device_hash if block_given? device_hash end |
#get_input(options) {|input_hash| ... } ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ruby_loggly.rb', line 29 def get_input() response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/#{[:id]}") input_hash=JSON.parse(response.to_str) yield input_hash if block_given? input_hash end |
#list_devices {|response_array| ... } ⇒ Object
43 44 45 46 47 48 |
# 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| ... } ⇒ Object
23 24 25 26 27 28 |
# 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) ⇒ Object
13 14 15 16 |
# 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) ⇒ Object
53 54 55 56 |
# File 'lib/ruby_loggly.rb', line 53 def remove_device() response = RestClient.delete("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/devices/#{[:id]}") response.code==204 ? true : false end |
#remove_input(options) ⇒ Object
39 40 41 42 |
# File 'lib/ruby_loggly.rb', line 39 def remove_input() response = RestClient.delete("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/inputs/#{[:id]}") response.code==204 ? true : false end |
#search(query) {|response.to_str| ... } ⇒ Object
18 19 20 21 |
# 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 |