class Quintly::QQL

Constants

API_VERSION
SERVICE_URL

Public Instance Methods

metric(metric) click to toggle source
# File lib/quintly/qql.rb, line 10
def metric(metric)
  call('metric', metric)
end
query(qql_query) click to toggle source
# File lib/quintly/qql.rb, line 14
def query(qql_query)
  call('qqlQuery', qql_query)
end

Private Instance Methods

api_client() click to toggle source
# File lib/quintly/qql.rb, line 20
def api_client
  connection = Faraday.new(SERVICE_URL)
  connection.basic_auth(
    configuration.username, configuration.password
  )
  connection
end
call(api, action) click to toggle source
# File lib/quintly/qql.rb, line 28
def call(api, action)
  url = URI.parse(URI.encode(
    "/#{API_VERSION}/qql?#{api}=#{action}&" +
    "startTime=#{configuration.start_time}&" +
    "endTime=#{configuration.end_time}&" +
    "interval=#{configuration.interval}&" +
    "profileIds=#{configuration.profile_ids}")
  )
  response = api_client.get(url)
  response.success? ? JSON.parse(response.body)['data'] : response.body
end