class LogentriesPullApi::Client
Constants
- LOGENTRIES_API_URL
Attributes
account_key[R]
log_key[R]
log_set_key[R]
Public Class Methods
new(account_key, log_set_key, log_key)
click to toggle source
# File lib/logentries_pull_api/client.rb, line 11 def initialize(account_key, log_set_key, log_key) @account_key = account_key @log_set_key = log_set_key @log_key = log_key end
Public Instance Methods
get(options = {})
click to toggle source
# File lib/logentries_pull_api/client.rb, line 18 def get(options = {}) response = fetch_response_from assemble_uri(options) raise LogentriesPullApi::Error, response['reason'] if response.is_a? Hash response end
Private Instance Methods
assemble_uri(options)
click to toggle source
# File lib/logentries_pull_api/client.rb, line 31 def assemble_uri(options) encoded_log_set_key = URI.encode log_set_key encoded_log_key = URI.encode log_key uri = URI.parse "#{LOGENTRIES_API_URL}/#{account_key}/hosts/#{encoded_log_set_key}/#{encoded_log_key}/" uri.query = URI.encode_www_form options.merge format: 'json' uri end
fetch_response_from(uri)
click to toggle source
# File lib/logentries_pull_api/client.rb, line 42 def fetch_response_from(uri) response = Net::HTTP.get_response uri JSON.parse response.body end