Skip to content

Commit

Permalink
Merge pull request #124 from teamlakana/feature-usage_by_month
Browse files Browse the repository at this point in the history
Feature - add support for /stats/usage_by_month
  • Loading branch information
thommahoney authored Apr 4, 2018
2 parents cd6008c + de94f1d commit 80994be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/fastly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def stats(opts)

# Returns usage information aggregated across all Fastly services and grouped by region.
#
# If the :by_month flag is passed then returns total usage information aggregated by month as well as grouped by service & region.
#
# If the :by_service flag is passed then returns usage information aggregated by service and grouped by service & region.
#
# Other options available are:
Expand All @@ -140,6 +142,7 @@ def stats(opts)
# See http://docs.fastly.com/docs/stats for details.
def usage(opts)
url = '/stats/usage'
url += '_by_month' if opts.delete(:by_month)
url += '_by_service' if opts.delete(:by_service)
client.get_stats(url, opts)
end
Expand Down
5 changes: 5 additions & 0 deletions test/stats_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def test_usage
assert(usage['meta'])
assert_equal 'success', usage['status']

usage = @fastly.usage(:from => FROM, :by_month => 1)
assert(usage)
assert(usage['meta'])
assert_equal 'success', usage['status']

usage = @fastly.usage(:from => FROM, :by_service => 1)
assert(usage)
assert(usage['meta'])
Expand Down

0 comments on commit 80994be

Please sign in to comment.