lib/vault-usage-client/client.rb in vault-usage-client-0.0.11 vs lib/vault-usage-client/client.rb in vault-usage-client-0.0.12
- old
+ new
@@ -150,10 +150,14 @@
# @param stop_time [Time] The end of the usage period, always in UTC,
# within which events must overlap to be included in usage data.
# @param exclude [Array] Optionally, a list of product names, such as
# `['platform:dyno:physical', 'addon:memcache:100mb']`, to be excluded
# from usage data.
+ # @param callback_url [String] The URL vault-usage will callback after generating
+ # usage events JSON
+ # @param snapshot [Boolean] Whether or not to return only events that were open
+ # at the start_time
# @raise [InvalidTimeError] Raised if a non-UTC start or stop time is
# provided.
# @raise [Excon::Errors::HTTPStatusError] Raised if the server returns an
# unsuccessful HTTP status code.
# @return [Array] A list of usage events for the specified user, matching
@@ -168,19 +172,20 @@
# detail: {<key1>: <value1>,
# <key2>: <value2>,
# ...}},
# ...]}
# ```
- def usage_for_user(user_hid, start_time, stop_time, exclude=nil, callback_url = nil)
+ def usage_for_user(user_hid, start_time, stop_time, exclude=nil, callback_url=nil, snapshot=false)
unless start_time.zone.eql?('UTC')
raise InvalidTimeError.new('Start time must be in UTC.')
end
unless stop_time.zone.eql?('UTC')
raise InvalidTimeError.new('Stop time must be in UTC.')
end
path = "/users/#{user_hid}/usage/#{iso_format(start_time)}/" +
- "#{iso_format(stop_time)}"
+ "#{iso_format(stop_time)}"
query = {}
+ query[:snapshot] = true if snapshot
unless exclude.nil? || exclude.empty?
query[:exclude] = exclude.join(',')
end
query[:callback_url] = callback_url if callback_url
connection = Excon.new(@url)