Created
March 21, 2014 11:15
-
-
Save jerzyn/9684047 to your computer and use it in GitHub Desktop.
Example Fetch Stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def api_call_application_usage(domain, provider_key, application_id, metric, from, to, granularity) | |
url = "https://#{domain}/stats/applications/#{application_id}/usage.xml?provider_key=#{provider_key}&metric_name=#{metric}&since=#{from}&until=#{to}&granularity=#{granularity}" | |
response = RestClient.get url | |
raise Exception.new("Wrong response code (#{response.code}) in request #{url}") if response.code!=200 | |
document = Nokogiri::XML(response.to_str) | |
return document.xpath("//usage/data/values").text.split(",") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment