vault-usage-client 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68c67490431226bad7e3226be45499e255db555e
4
- data.tar.gz: acad611c2b6b788c30113d0df48ed4d8979c56fb
3
+ metadata.gz: 396f74ea5ff90f39ec688dba59339a3eb7abcd59
4
+ data.tar.gz: b102e37d9f160b8ea762837bbbc3ff62ee7fd5d3
5
5
  SHA512:
6
- metadata.gz: d65b4dc26dc5ec6155be8714a04dbb2dba125d4ea1b929dfd79422448215ad0376f487b37e0409c4146eecffc82adb163bb71c0d95529971bc1730ea87aabbba
7
- data.tar.gz: 378ebbab8db4dc0e4a27bd7d75a1dd679b5b54bccfb333929ec032cfcbfd7e3a9367efb0c59f8a8a21c81d42a641838a99198c06dc7bfb3728ea21f44fc875f2
6
+ metadata.gz: 72451c5898b32134424a27efdc97b40213866c6dee9cf80fdbc88a4d5071dcfc75dd6748e4697b72c92cf11f663c57e1788719d3c316ff5c8a222107b6a85805
7
+ data.tar.gz: bd44043d3dd67c23c7fef8f0319fc818679fb8504d4a271cfc17330de548b2be1321d34eab89c973930c52fa28995b8241e95f4980c14614c62b858dca9c0d25
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vault-usage-client (0.0.11)
5
- colorize (~> 0.7.3)
6
- excon (~> 0.39.5)
7
- multi_json (~> 1.10.1)
4
+ vault-usage-client (0.0.12)
5
+ colorize
6
+ excon
7
+ multi_json
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -82,3 +82,6 @@ DEPENDENCIES
82
82
  vault-test-tools
83
83
  vault-usage-client!
84
84
  yard
85
+
86
+ BUNDLED WITH
87
+ 1.10.6
data/README.md CHANGED
@@ -118,7 +118,7 @@ The `events` result is an `Array` of objects matching this format:
118
118
  detail: {<key1>: <value1>,
119
119
  <key2>: <value2>,
120
120
  ...}},
121
- ...]}
121
+ ...]
122
122
  ```
123
123
 
124
124
  In some cases it can be useful to exclude event data for certain
@@ -134,6 +134,28 @@ events = client.usage_for_user(user_hid, start_time, stop_time,
134
134
 
135
135
  You can pass one or more product names to exclude.
136
136
 
137
+ #### Retrieving a single usage event
138
+
139
+ A usage event can be retrieved with the client:
140
+
141
+ ```
142
+ event_id = '3b1086ea-07df-4324-a35f-b28a1474bd9b'
143
+ event = client.usage_for_event(event_id)
144
+ ```
145
+
146
+ The `event` result is an object matching this format:
147
+
148
+ ```ruby
149
+ {id: '<event-uuid>',
150
+ product: '<name>',
151
+ consumer: '<consumer-hid>',
152
+ start_time: <Time>,
153
+ stop_time: <Time>,
154
+ detail: {<key1>: <value1>,
155
+ <key2>: <value2>,
156
+ ...}}
157
+ ```
158
+
137
159
  ### App ownership events
138
160
 
139
161
  App ownership events represent ownership of an app, for a period of
@@ -152,6 +152,10 @@ module Vault::Usage
152
152
  # @param exclude [Array] Optionally, a list of product names, such as
153
153
  # `['platform:dyno:physical', 'addon:memcache:100mb']`, to be excluded
154
154
  # from usage data.
155
+ # @param callback_url [String] The URL vault-usage will callback after generating
156
+ # usage events JSON
157
+ # @param snapshot [Boolean] Whether or not to return only events that were open
158
+ # at the start_time
155
159
  # @raise [InvalidTimeError] Raised if a non-UTC start or stop time is
156
160
  # provided.
157
161
  # @raise [Excon::Errors::HTTPStatusError] Raised if the server returns an
@@ -170,7 +174,7 @@ module Vault::Usage
170
174
  # ...}},
171
175
  # ...]}
172
176
  # ```
173
- def usage_for_user(user_hid, start_time, stop_time, exclude=nil, callback_url = nil)
177
+ def usage_for_user(user_hid, start_time, stop_time, exclude=nil, callback_url=nil, snapshot=false)
174
178
  unless start_time.zone.eql?('UTC')
175
179
  raise InvalidTimeError.new('Start time must be in UTC.')
176
180
  end
@@ -178,8 +182,9 @@ module Vault::Usage
178
182
  raise InvalidTimeError.new('Stop time must be in UTC.')
179
183
  end
180
184
  path = "/users/#{user_hid}/usage/#{iso_format(start_time)}/" +
181
- "#{iso_format(stop_time)}"
185
+ "#{iso_format(stop_time)}"
182
186
  query = {}
187
+ query[:snapshot] = true if snapshot
183
188
  unless exclude.nil? || exclude.empty?
184
189
  query[:exclude] = exclude.join(',')
185
190
  end
@@ -2,7 +2,7 @@ module Vault
2
2
  module Usage
3
3
  class Client
4
4
  # The `Vault::Usage::Client` gem version.
5
- VERSION = '0.0.11'
5
+ VERSION = '0.0.12'
6
6
  end
7
7
  end
8
8
  end
data/test/client_test.rb CHANGED
@@ -278,6 +278,16 @@ class ClientTest < Vault::TestCase
278
278
  @client.usage_for_user(@user_hid, @start_time, @stop_time, nil,'http://example.com'))
279
279
  end
280
280
 
281
+ def test_usage_for_user_with_callback_url_and_snapshot
282
+ Excon.stub(method: :get) do |request|
283
+ assert_equal({callback_url: 'http://example.com', snapshot: true}, request[:query])
284
+ Excon.stubs.pop
285
+ {status: 200, body: MultiJson.dump({job_id: 'DEADBEEF'})}
286
+ end
287
+ assert_equal('DEADBEEF',
288
+ @client.usage_for_user(@user_hid, @start_time, @stop_time, nil,'http://example.com', true))
289
+ end
290
+
281
291
  # Client.usage_for_user comma-separates product names, when many are
282
292
  # provided in the exclusion list, and passes them to the server using a
283
293
  # single query argument.
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
  gem.executables = ['vault-usage']
19
19
 
20
- gem.add_dependency 'excon', '~> 0.39.5'
21
- gem.add_dependency 'multi_json', '~> 1.10.1'
22
- gem.add_dependency 'colorize', '~> 0.7.3'
20
+ gem.add_dependency 'excon'
21
+ gem.add_dependency 'multi_json'
22
+ gem.add_dependency 'colorize'
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-usage-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
@@ -9,50 +9,50 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-26 00:00:00.000000000 Z
12
+ date: 2016-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: excon
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.39.5
20
+ version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.39.5
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: multi_json
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 1.10.1
34
+ version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 1.10.1
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: colorize
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 0.7.3
48
+ version: '0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.7.3
55
+ version: '0'
56
56
  description: Client for Vault::Usage
57
57
  email:
58
58
  - csquared@heroku.com